Solution 1
This is the most simple way to append simple log strings to a file if DEBUG is defined.
#include "stdio.h" void WriteLogFile(const char* szString) { #ifdef DEBUG FILE* pFile = fopen("logFile.txt", "a"); fprintf(pFile, "%s\n",szString); fclose(pFile); #endif }
Solution 2
C++ answer for the same thing
#include
void write_text_to_log_file(const std::string &text) { std::ofstream log_file( "log_file.txt", std::ios_base::out | std::ios_base::app ); log_file << text << std::end; }
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C++/문자열 로그 파일 기록
last modified 2018-05-15 15:48:49