![]() |
|
#1
|
|||
|
|||
Compare today's date with date last runI am working on a project and I want it to be in real time.
It is a restuarant program that lets you buy your meal. I am to have a specials menu that changes, but I want this to change in real time. So what I would like is to have some function to have the previous date run saved to compare it to the new date run. something like: CPP / C++ / C Code:
Regards, Gene Saika |
|||
|
#2
|
|||
|
|||
Re: compare today's date with date last runQuote:
|
|
#3
|
|||
|
|||
Re: compare today's date with date last runIt looks like you are trying to use macros to determine the date of execution (realize that __DATE__ is a macro). These macros are expanded at compile time and thus would require a daily compile to ensure that they are current. Furthermore, you can not assign to a macro (well, you can depending on how you define it but that could be considered bad practice).
What would likely be the best solution for you would be to store a variable somewhere with the last date (get it however your system allows). Each time you want to check compare the current date (again, by whatever means your system provides) with that variable. There are standard utilities to accomplish these actions on any well-known system. __________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#4
|
|||
|
|||
Re: Compare today's date with date last runI know I can save the date to a file and open that file everytime the program is run, but would there be another option? I am trying to do this without too many extra files.
|
|
#5
|
|||
|
|||
Re: Compare today's date with date last runQuote:
Quote:
If your comments revolves around data saved in multiple files, then another alternative is combining them. |
|
#6
|
|||
|
|||
Re: Compare today's date with date last runFor now two files might be too many.
So if there isn't another way then I will have to just save the file, but I'd rather another way. Yes I know that anything I save to a local varible would be erased and that is why I mentioned the __DATE__ thing. If doign this without saving to a file is not possible then I will, of course, just save to a file. |
|
#7
|
|||
|
|||
Re: Compare today's date with date last runIf you have multiple values to store there is no reason you cant store them all in a single file, in fact that is how some databases work.
The fact is when your program ends its memory is erased (not really, just reassigned) to make room for some other process. If you need any part of that memory before it is gone you need store it to some place persistent. This can be a database, flat file, removable media, and so on - each with a varying level of difficulty in execution. Your other option, as I mentioned before, is to just keep your program running and use a variable within the program to track the current value. This is what program design is all about; what fits best for your situation can only be decided by you. __________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#8
|
|||
|
|||
Re: Compare today's date with date last runQuote:
If you are dealing with Windows, you could write the value into the registry, but this is also an advanced subject which I recommend you avoid. It would also tie your solution to a specific operating system. As stated before, I find it hard to believe that your instructor wants such bells & whistles. |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Write the declaration for a Date object | Sosy | C++ Forum | 6 | 26-Oct-2007 10:21 |
| date of Yesterday | ctrohaya | MySQL / PHP Forum | 6 | 29-Nov-2006 03:37 |
| Date problem | coolio2005 | Java Forum | 1 | 21-Mar-2006 08:07 |
| Limit combo box and date time picker choice according to database created in folder | shinyhui | C++ Forum | 0 | 22-Feb-2005 21:16 |
| Limit combo box and date time picker choice according to database created in folder | shinyhui | MS Visual C++ / MFC Forum | 0 | 22-Feb-2005 03:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The