Created
November 7, 2015 12:56
-
-
Save LusainKim/dc3eb19bc51b1322a518 to your computer and use it in GitHub Desktop.
DebugSample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <iostream> | |
#include <string> | |
#include <fstream> | |
using namespace std; | |
#define USE_DEBUG_OUTPUT_TEXT | |
#if defined(USE_DEBUG_OUTPUT_TEXT) | |
ofstream fs; | |
bool bOpenFs = false; | |
#define DWRITE(str) (fs << (str)) | |
#else | |
#define DWRITE(str) | |
#endif | |
inline void initializeOutputlog() | |
{ | |
#if defined(USE_DEBUG_OUTPUT_TEXT) | |
fs.open("log.txt", ios::out | ios::trunc); | |
fs.imbue(locale("ko-kr")); | |
bOpenFs = true; | |
#endif | |
} | |
inline void CloseOutputlog() | |
{ | |
#if defined(USE_DEBUG_OUTPUT_TEXT) | |
if (bOpenFs) { fs.close(); } | |
#endif | |
} | |
int main() | |
{ | |
initializeOutputlog(); | |
string str; | |
while (1) | |
{ | |
getline(cin,str,'\n'); | |
if (str == "quit") break; | |
str += '\n'; | |
OutputDebugString(str.c_str()); | |
DWRITE(str); | |
} | |
CloseOutputlog(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment