bobby101
asked on
User input date
i want a user to enter a date than get the week number so far i know how to get the week number by using strftime(date,3,"%W",&date ) but dont know how to pass it into date
ASKER
i have been playing around with it but its not doing what i was please help
int week;
char date[3];
int year, month ,day;
struct tm timei;
cout <<"dd-MM-yyyy";
cin>> day >> month >> year;
timei.tm_yday = day;
timei.tm_mon = month-1;
timei.tm_year += year-1900;
strftime(date,3,"%W",&timei);
week = atoi(date);
cout << week;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.cplusplus.com/reference/clibrary/ctime/tm/
So, you'll need to fill such a struct with the data you get from the user. Once you have that, you can pass it to strftime.