What function are you using to get the time?
Here's a simple example using the time() function.
The kbhit() function is true if a key was pressed. It's in conio.h on my compiler.
Code:
time_t tim, time_last;
char *print_time;
time_last = time(NULL);
print_time = ctime(&time_last);
cout << print_time << endl;
do {
tim = time(NULL);
if (tim != time_last)
{
print_time = ctime(&tim);
cout << print_time << endl;
time_last = tim;
}
} while (!kbhit());
I guess you could use GetTickCount(), though it's in millisecs.