I'd like to write a function in C that takes the current system date adds a user defined number of days and returns the new date. Im new to C so Id like any suggestions . Thanks in Advance.
Ive been looking at time.h, still need to see some code to do that. Ive searched the web but found little help. Thanks.
What have you found out? What format is the system time if you need to add to it? What function(s) do you need to call?
1. get current time in the form of struct tm (two function calls to do that)
2. Get number of days from user
3. Add days from #2 above to tm_mday obtains in #1 above
4. call mktime() to normalize all struct tm members.
Note: you can't do silly things like advance number of days beyone the limits of time_t or subtract them to that the result is before 1 Jan 1970. If you want to do that then you will have to use something else, such as write your own function to handle such times.