Can some one tell me how do i display real time in c++. what i mean is that while the program is running you can see the seconds and or minutes counting down like a real clock h
Not in C++ (in C/Win32) but works.
#include
#include
int _tmain(int argc, _TCHAR* argv[])
{
SYSTEMTIME stime; //structure to store system time (in usual time format)
FILETIME ltime; //structure to store local time (local time in 64 bits)
FILETIME ftTimeStamp;
char TimeStamp[256];//to store TimeStamp information
while (true){
////Prepare data needed to output the time stamp:
GetSystemTimeAsFileTime(&ftTimeStamp); // Gets the current system time
FileTimeToLocalFileTime (&ftTimeStamp,<ime);//convert in local time and store in ltime
FileTimeToSystemTime(<ime,&stime);//convert in system time and store in stime
sprintf(TimeStamp, "%d:%d:%d, %d.%d.%d \r",stime.wHour,stime.wMinute,stime.wSecond, stime.wDay,stime.wMonth,stime.wYear);
printf(TimeStamp);
Sleep(1000);
}
system("pause");
return 0;
}