__TIME__ !change value

Hello
I want to add time that change every 1 second to my simple c++ game I am working on now, but it seems that once __TIME__ is used, it will never change?

1
2
3
4
5
6
7
8
9
10
  #include <iostream>
  using namespace std;
  int main()
       {  
           while(1)
           {
                  cout<<__TIME__<<endl;
           }
       }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
using namespace std;
int main()
{  
    
    string time=__TIME__;
    while(1)
    cout<<time<<endl;
    
}



Last edited on
__TIME__ is a string literal in the form "hh:mm:ss" containing the time at which the compilation process began.
http://www.cplusplus.com/doc/tutorial/preprocessor/

Use the time() function instead.
http://www.cplusplus.com/reference/ctime/time/?kw=time
Topic archived. No new replies allowed.