![]() |
|
#1
|
|||
|
|||
Date and timeI am working on a program for a restaurant menu where the user can buy meals, drinks, and so forth. I have the basic code in place and want to add in a specials menu that changes daily. At this time I am using __DATE__ and __TIME__ to get the date and time.
My issue is that I would like the time to change as if it was a clock. So how would I manage this ? Regards, Gene Saika |
|||
|
#2
|
|||
|
|||
Re: date and timeHave a look at ctime
__________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#3
|
|||
|
|||
Re: date and timeJust to be certain... calling ctime(t) would make it so that if the user were to go to a different part of the program and come back to where the clock is the time would be the time at that moment?
Also would the time be constantly refreshing or at least refreshable? |
|
#4
|
|||
|
|||
Re: date and timeYes. Look at the following example:
CPP / C++ / C Code:
Quote:
__________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#5
|
|||
|
|||
Re: date and timeThank you that should work perfectly.
Would you mind explaining to me the use of unistd.h I have never heard of that header file. |
|
#6
|
|||
|
|||
Re: date and timeMy system man pages (it is a Linux system) say that the required header for sleep is unistd.h
Some systems may work without it, but I have it there for completeness. __________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#7
|
|||
|
|||
Re: date and timeok thank you again
|
|
#8
|
|||
|
|||
Re: Date and timeAfter implamenting the code into my program i found that it does work.
Now I need this to refresh constantly and still display other things after that and get input from them. This is how I have the code so far ( not the full code but an example) CPP / C++ / C Code:
I figure I could get the program to clear the line in the while loop and that would fix the repeating of the info, but I don't know how to do that. Also I need the code to still ask the user which option they want and get the input. I am using windows OS. Regards, Gene Saika |
|
#9
|
|||
|
|||
Re: Date and timeI'm not sure what you are trying to do here.
Are you looking to have the user input some value and then display the time that input was read? Or are you looking to continually output the time until a user makes a selection? If you put a display/sleep execution within a while loop and do not change the conditional to that loop (ct == 0 in your example) that is what is called an infinite loop. You may have other intentions. Please clarify __________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#10
|
|||
|
|||
Re: Date and timeI am wanting the time to be like a clock that ran in the of my program while everything else still continues to move on.
So yes I want the time to be in an infinite loop so that is constantly refreshing, but I want the rest of the program to keep going. So when run the program should have a digital clock running with the current time while still letting the user input and move about the program. |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Get the date / time difference with PHP | admin | PHP Code Library | 4 | 16-Nov-2006 00:43 |
| Date and time formats from mysql | jcgkiwi | MySQL / PHP Forum | 1 | 21-Jun-2005 09:37 |
| 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