Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Past and Future Time with C

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
My program in C needs to verify the validity
of input dates. For example, if the user
inputs February 33, the program should spot
this as invalid. I know Linux can do a lot
with dates. For example, the cal command can
produce any year's calander. So there must be
an easy way to do this.
I know how to get the current data/time with
ctime() no problem. It's just past and future
valid dates I have a problem with.
Also, in another part of this program, it has
to produce dates corresponding to the following
strings: Yesterday, Today, Tomorrow, Today + 2
Anybody got any ideas how I can do this in C ?
 
One way that occurs to me is to assign values for the months in order:
int month[10] = 31;
Then write a sort function that defines max_length by subscript.
There is a C forum here that is very good where you could get a detailed answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top