Reputation: 6323
I get the same string result for curTime and pastTime when I use "ctime" even though the actual values at curTime and pastTime are different by 600 seconds.
How am I getting the same string time for both when using ctime?
thx
struct _timeb timebuffer;
_ftime(&timebuffer);
const time_t curTime = (const time_t)timebuffer.time;
const time_t pastTime = curTime - (const time_t)600;
s.Format("%d %s\n%d %s", curTime, ctime(&curTime), pastTime, ctime(&pastTime) );
MessageBox(s);
Upvotes: 0
Views: 225
Reputation: 206699
ctime
returns a string that can be statically allocated.
So one of your two calls is overwriting the string that the other one generates.
You'll need to split that into two print statements, or copy (string copy) the return values of ctime
into temporaries.
Upvotes: 4