So far I have this bit of code for adding number of days to a date using the time.h module:
This works ok until you add 30 or more days to the date, then it'll give me something like>>September 53 2011<< if I add 40 days .Code:int main(int argc, char **argv)
{
int numDays;
printf ("Enter number of days to add ");
scanf ("%d", &numDays);
time_t now = time(NULL);
struct tm* tm = localtime(&now);
tm->tm_mday += numDays;
cout << asctime(tm);
return 0;
}
What have I done wrong??