[ create a new paste ] login | about

Link: http://codepad.org/f1W8HjFg    [ raw code | output | fork ]

C++, pasted on Jun 13:
void WriteLog(const char* strTemp,const char* strGrade)
{
	errno_t err;
    CString strCheckFileName;
    FILE * pFile;    
	SYSTEMTIME st ;	
	GetLocalTime(&st);
	CString STORE_DAY;					
	STORE_DAY.Format("%04u-%02u-%02u",st.wYear,st.wMonth,st.wDay);
	strCheckFileName.Format("%sFDC_%s.log",logDir,STORE_DAY);

	CString STORE_TIME;
	STORE_TIME.Format("%04u-%02u-%02u-%02u:%02u:%02u",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
	try
	{
        //pFile = fopen (strCheckFileName, "a+");	    
		err = fopen_s(&pFile,strCheckFileName,"a+");
		if ( err == 0)
		{fprintf(pFile,"%s %s %s\n" , STORE_TIME,strGrade,strTemp);}

	}
	catch(...)
	{
	    //pFile = fopen ("Err.log", "w");	    
		err = fopen_s(&pFile,"Err.log","a+");
		if ( err == 0)
		{fprintf(pFile,"%s %s %s\n" , STORE_TIME,strGrade,strTemp);}

	}
	if (err == 0)
	{fclose (pFile);}
}

CString getFileName(LPCTSTR lpPath) 
{ 
	CString tempStr;
	tempStr = "";
    TCHAR szFind[MAX_PATH] = {_T("\0")}; 
    WIN32_FIND_DATA findFileData;     
  
    _tcscpy_s(szFind, MAX_PATH, lpPath); 
    _tcscat_s(szFind, _T("*.fdc"));   
    HANDLE hFind = ::FindFirstFile(szFind, &findFileData); 
    if (INVALID_HANDLE_VALUE == hFind) 
    { 
        return tempStr; 
    } 
           
    if (findFileData.cFileName[0] != _T('.')) 
    {
        tempStr.Format("%s%s", lpPath, findFileData.cFileName); 

    }    

    ::FindClose(hFind); 
	return tempStr;
} 


Output:
1
2
3
In function 'void WriteLog(const char*, const char*)':
Line 4: error: 'errno_t' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: