hi all,
I'm trying to print out the current time using C++. I'm using Microsoft visual studio 2008..
Getlocaltime() functin doesn't seem to work.. What's the problem? Any help is appreciated..Code:#include <windows.h> #include <stdio.h> #include <time.h> #ifndef WINDOWS #include <sys/time.h> #endif #ifdef WINDOWS SYSTEMTIME beg; #else struct timeval beg; struct tm *t; #endif #ifdef WINDOWS GetLocalTime( &beg ); printf( "%02d:%02d:%02d:%06d\n", beg.wHour, beg.wMinute, beg.wSecond, beg.wMilliseconds * 1000 ); #else gettimeofday( &beg, NULL ); t = localtime( &beg.tv_sec ); printf( "%02d:%02d:%02d.%06d\n", t->tm_hour, t->tm_min, t->tm_sec, (int) beg.tv_usec ); #endif



LinkBack URL
About LinkBacks


