Link to home
Start Free TrialLog in
Avatar of Kev_Mc01
Kev_Mc01

asked on

C++ timer.h header file

Hi,

Could you tell me how the timer.h header file works.  Im currently a beginner in C++ programming and creating a phonebox in C++ for an assignment, and it requires money to be counted down, ive never used the timer.h before so unsure about the code that is required.

Thanks
Avatar of n_fortynine
n_fortynine

There doesn't seem to be a <timer.h> not as I know of. There is one that's called time.h probably that's what you meant? In this case, why would you want to use time.h? What task are you trying to accomplish here?

>> it requires money to be counted down
I'm not clear what you mean here...
Avatar of Kev_Mc01

ASKER

Sorry its the time.h header file.
Basically the program that i am trying to create is a phonebox.  It asks the user what kind of call they would like to make (long distance or local) and to enter their coinage, for example, 10 p.  It will then ask the user how many 10p they are entering, e.g. 5, it would then calculate 10 mulitplied by 5 to give 50 pence, 50 would be equal to 50 seconds (roughly) for the phone call.  I need to use a time to countdown the 1 p every second, but im unsure how to do this.

Thanks
how accurate do you want this counting to be? (based on what you're doing it doesn't seem that you have to be *precisely* accurate--unless you're trying to develop a real-time application) do you need to process anything during this duration (each second)? the easiest way to *count* the seconds is to make the system "sleep" for a certain amount of time e.g.

for(count = 50; count; --count)
   sleep(1000);  //1000 miliseconds.

this will effectively pause the system for roughly 50 seconds (or how much longer/shorter you want it to). To use sleep(), include <unistd.h> or if you are using VC++ MFC, use ::sleep(/*milisecs*/). Will this do? =)
It doesnt have to be precisely accurate, when the time is counting down there is no user input in that time, its just basically to simulate a call so i think what your saying is right.  Is it possible for the program to display each second as its counting down?  So that the user knows when they are nearly out of credit to enter more calls.  I have done a similar program to this in Visual Basic, but like i say im new to C++, thanks for the code.
ASKER CERTIFIED SOLUTION
Avatar of n_fortynine
n_fortynine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Kev_Mc01:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Thanks for all the help, the timer was able to function and i ended up recieving a Merit for that assignment, so thanks again :)