代码
1、
FILE *fp = fopen("C:\\1.txt","a+");
char strBuf[512];
sprintf(strBuf,"%s\r\n","log");
fwrite(strBuf,1,strlen(strBuf),fp);
fclose(fp);
2、
// 写日志功能
void WriteLog(LogInfoType iLogType ,char *pLog)
{
//环境变量的判断
char *strENV;
strENV = ::getenv( "GeoGlobeENVLOG" );
if( strENV == NULL ) return;
if( strcmp(strENV ,"OPEN") != 0) return;
FILE* fp = NULL;
char strLogPath[MAX_PATH] = {0};
memset(strLogPath,0,MAX_PATH);
sprintf(strLogPath,("c:\\dataset.log"));
fp = fopen(strLogPath, "a");
if(fp == NULL)
{
fp= fopen(strLogPath,"w");
}
int iLen = 0;
char strInfo[3072]={0};
memset(strInfo,0,3072);
GetNowString(strInfo,&iLen, 3072);
strcat(strInfo,_T(" : "));
if(fp)
{
GetLogFormat( iLogType ,strInfo , 0);
strcat(strInfo, pLog);
GetLogFormat( iLogType ,strInfo , 1);
fwrite(strInfo, 1, strlen(strInfo), fp);
fclose(fp);
}
}
FILE *fp = fopen("C:\\1.txt","a+");
char strBuf[512];
sprintf(strBuf,"%s\r\n","log");
fwrite(strBuf,1,strlen(strBuf),fp);
fclose(fp);
2、
// 写日志功能
void WriteLog(LogInfoType iLogType ,char *pLog)
{
//环境变量的判断
char *strENV;
strENV = ::getenv( "GeoGlobeENVLOG" );
if( strENV == NULL ) return;
if( strcmp(strENV ,"OPEN") != 0) return;
FILE* fp = NULL;
char strLogPath[MAX_PATH] = {0};
memset(strLogPath,0,MAX_PATH);
sprintf(strLogPath,("c:\\dataset.log"));
fp = fopen(strLogPath, "a");
if(fp == NULL)
{
fp= fopen(strLogPath,"w");
}
int iLen = 0;
char strInfo[3072]={0};
memset(strInfo,0,3072);
GetNowString(strInfo,&iLen, 3072);
strcat(strInfo,_T(" : "));
if(fp)
{
GetLogFormat( iLogType ,strInfo , 0);
strcat(strInfo, pLog);
GetLogFormat( iLogType ,strInfo , 1);
fwrite(strInfo, 1, strlen(strInfo), fp);
fclose(fp);
}
}