![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Add days to date without affecting the original input dateI know how to add days to date, but i just wan to display the after-added date. I still need the original date. What can i go about it
CPP / C++ / C Code:
When i input a date, it will do all sort of operations before going to returnDate() to print out. I able to calculate the add days to date, but i dun wan it to affect the input date when i print out. What should i do? |
|||
|
#2
|
|||
|
|||
Re: add days to date without affecting the original input dateanyone have some idea or hint to give me?
when i enter example 20 jan 2008...then i add 20 days to it...the result is 9 feb 2008...but i wan when i prompt to print the date, it still contain 20 jan 2008 |
|
#3
|
|||
|
|||
Re: Add days to date without affecting the original input dateanyone can help...give me some advice also can...
|
|
#4
|
||||
|
||||
Re: Add days to date without affecting the original input dateOne possible way is to store the original day into a temporary variable, do the necessary calculations using that variable instead. This will leave the original value intact.
Oh, and just for suggestion -- instead of repeating the month's in a hard-coded way, because you have declared an array of months, consider replacing the switch with something like this: CPP / C++ / C Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#5
|
|||
|
|||
Re: add days to date without affecting the original input dateQuote:
Personally, I think you will find it simpler to exploit the functions found in ctime.h -- especially the functions:Examples can be found at the links given above. |
|
#6
|
|||
|
|||
Re: Add days to date without affecting the original input dateQuote:
how to store it inside a temp variable can teach me, demo me example. |
|
#7
|
|||
|
|||
Re: Add days to date without affecting the original input dateanyone know how to store original day into temp variable...can someone guide me
|
|
#8
|
||||
|
||||
Re: Add days to date without affecting the original input dateAgain, this is only one possibility...
CPP / C++ / C Code:
EDIT: Like ocicat already pointed out, this should starting 'painting the picture' of date handling not being so trivial. Unless you are limited by the assignment, check into the functions that he offered in post #5. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trouble integrating console code into GUI | Barman007 | Java Forum | 18 | 15-May-2008 13:05 |
| Scanning dilemma (fscanf and fgets) | aijazbaig1 | C Programming Language | 10 | 29-Mar-2008 04:58 |
| Write the declaration for a Date object | Sosy | C++ Forum | 6 | 26-Oct-2007 09:21 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 10:53 |
| Script needed for letting user input a few days of data for tracking and analysis. | tradertt | MySQL / PHP Forum | 3 | 06-Mar-2003 02:54 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The