I am trying to display current time on output window of Visual Studio. I need it for debugging purpose. Since printf() output doesn't print to output window of Visual Studio, i need to use OutputDebugString().
Code compiles correctly but output doesn't come out correctly. Can someone help me out here ? Thanks !
char buff[100];
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(buff, "[%d %d %d %d:%d:%d]", timeinfo->tm_mday, timeinfo->tm_mon + 1, timeinfo->tm_year + 1900, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
OutputDebugString(LPCWSTR(buff));
OUTPUT Window of Visual Studio prints :
?‹???????]
Expected: Date and time is printed correctly.