I want to output the time and loop it so the time is constantly being updated without outputting the same line again and again so I thought id overwrite the line by using the carriage but it doesn't seem to work and I don't know why, is it to do with Xcode?? I have previously read other posts on stack overflow regarding \r and tried to adapt the answers to my code but none of the solutions seemed to work nor are they related to ios/Xcode. I am also assuming that the problem may have something to do with the Xcode console, being as how it is not a terminal (however I am not to sure)
#include <iostream>
#include <time.h>
using namespace std;
int main(int argc, const char * argv[]) {
//Loop Forever
for(;;){
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
cout << "The current date/time is: " << asctime(timeinfo) << "\r";
}
return 0;
}
output:
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017
The current date/time is: Fri Feb 10 17:20:43 2017