请原谅我的无知..我知道一些,但不知何故仍然对基础知识感到模糊!?!你能考虑这个简单的例子并告诉我将日志消息传递给'writeLogFile'的最佳方法吗?
void writeLogFile (ofstream *logStream_ptr)
{
FILE* file;
errno_t err;
//will check this and put in an if statement later..
err = fopen_s(&file, logFileName, "w+" );
//MAIN PROB:how can I write the data passed to this function into a file??
fwrite(logStream_ptr, sizeof(char), sizeof(logStream_ptr), file);
fclose(file);
}
int _tmain(int argc, _TCHAR* argv[])
{
logStream <<"someText";
writeLogFile(&logStream); //this is not correct, but I'm not sure how to fix it
return 0;
}