+ 1
Any Genius who give me Cpp code for count no.ofdays in two different dates of different years
Its hard but for inteligent it's easy
3 odpowiedzi
+ 2
To take user input you would have to parse the string into a 'tm' struct. Try something like:
char *input = "24/12/2016";
struct tm t1;
strptime(input, "%D", &t1);
+ 1
#include <iostream>
#include <ctime>
using namespace std;
int main() {
struct tm t1 = {0,0,0,24,12,114};
struct tm t2 = {0,0,0,2,7,116};
time_t date1 = mktime(&t1);
time_t date2 = mktime(&t2);
double diff = difftime(date2, date1) / (3600 * 24);
cout << diff << " days" << endl;
cout << ctime(&date1);
cout << ctime(&date2);
return 0;
}
0
Can we accept dates from user