Actually i am designing a movie ticket booking program and i need the program to display the current date , tomorrow's date and day after tomorrow's date so that the customer can decide on which day he wants the ticket to be booked.
I further want that date to be printed into the ticket which is stored in a text file along with other information about his ticket.
My bad. I'm using Visual Studio 9.0. I would think your namespace problem is only related to cout and endl, not to the use of _strtime(). To avoid using iostream's output functions, try using printf() instead:
What is all this? Can't anyone provide a solution that uses just the standard library? I damn you to Hell, Borland!
1 2 3 4 5 6 7 8
time_t secs=time(0);
tm *t=localtime(&secs);
//This prints the date in ISO format.
printf("%04d-%02d-%02d\n"t->tm_year+1900,t->tm_mon+1,t->tm_mday);
//This prints the date and time in ISO format.
printf("%04d-%02d-%02d %02d:%02d:%02d\n",
t->tm_year+1900,t->tm_mon+1,t->tm_mday,
t->tm_hour,t->tm_min,t->tm_sec);