C++/문자열 로그 파일 기록 Edit Diff Refresh Backlink Random Search History Help Setting Hide Show 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; } 이 글에는 0 개의 댓글이 있습니다. Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus