Link to home
Start Free TrialLog in
Avatar of ASWIN
ASWIN

asked on

to find the previous date

A program in C to accept a date and to print its previous date and its next date
Avatar of AlexVirochovsky
AlexVirochovsky

again homework!
How do you guys guess that it is homework problem? ASWIN has no profile.
Sometimes problems are simple like elemetary homework problems but not always.
ASKER CERTIFIED SOLUTION
Avatar of aperdon
aperdon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forget the previous answer, here is more
use the tm_yday item in the tm struct to set the day. Use the localtime and strftime functions, and the struct tm.

time_t now:
struct tm *tmnow;
struct tm tmtomorrow:
char szTomorrow[128]:

now = time(NULL);
tzset();
tmnow = localtime();
memset(&tmtomorrow,0,sizeof(struct tm));
tmtomorrow.tm_yday = tmnow->tm_yday + 1;
strftime(szTomorrow,128,"%x",&tmtomorrow);