I would like to know how to put a realtime timer in my program, like a stopwatch. I tried using the Time_t function but it can only display time when an event occurs. Maybe someone can tell me how to make a timer wich does not need a 'direct' event.(just like the computer clock)
you could use the GetTickCount() function. It returns the number of milliseconds since your program started.
make a variable to hold a starting point, and then where you want to stop would be stored in a second variable. subtract the second from the first to get the total time in milliseconds.
int a = GetTickCount();
// the thing you want to time
int b = GetTickCount();
int totalTime = b - a;
I know what you mean, and that's exactly what I did before. What I really mean is a timer that displays time during the program, even when no event occurs. Imagine a program that does cout<<"hi"; each second.(just as an example ofcourse)
search msdn for SetTimer function, it's what you are looking for, this function will send WM_TIMER message every x ms (you specify)