i have a file, ‘date.txt’ which has date in it. Like,
Mon Oct 13 09:37:08 2009.
Now i want to compare this date with system date. How can i compare dates in C++.?
I used this code to get the contents from the file ‘date.txt’
string date;
while ( inDateFile >>date) //inDateFile is an ifstream object
cout<<date<<endl;
And this code to get system date,
time_t timer;
struct tm *tblock;
timer = time(NULL);
tblock = localtime(&timer);
string str = asctime(tblock);
Now how can i compare these two dates.?
Parse values, use
std::mktimefunction to gettime_tand now usestd::difftimeto get the difference.