timer

i need to make a program that says how long the program has been open in seconds this is what i got so far but its not working.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <time.h>

int main() 
{
     time_t seconds;
     int iIndex = 0;
     seconds = time (NULL);
     while (iIndex < 5)
     {
           std::cout << ++iIndex << std::endl;
     }
     std::cout << seconds/3600 << std::endl;
     system ("pause");
     return iIndex;
}
clock() gets the amount of time in milliseconds since the program started. So you won't even need to record the time at the start of the program.

Topic archived. No new replies allowed.