- 论坛徽章:
- 0
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define FAILED -1
#define SUCCESS 10
FILE *LogFile;
int OpenLogFile( char *FilName )
{
char itasLogFile[256];
memset( itasLogFile, 0x00, sizeof( itasLogFile ) );
if( getenv( "ITASLOGDIR" ) == NULL )
{
return FAILED;
}
memcpy( itasLogFile, getenv( "ITASLOGDIR" ), strlen( getenv( "ITASLOGDIR" ) ) ); /*保存环境变量 */
strcat( itasLogFile, "/" );
strcat( itasLogFile, FilName );
if( ( LogFile = fopen( itasLogFile, "a" ) ) == NULL )
{
return FAILED;
}
if( 0 != ( setvbuf( LogFile, NULL, _IONBF, 0 ) ) )
{
return FAILED;
}
return SUCCESS;
}
int main( void )
{
putenv( "ITASLOGDIR=." );
OpenLogFile( "aa" );
fclose( LogFile );
return 0;
}
| 简单测试之后 没有楼主所说问题呀
请检查你的程序 |
|