| | |
Help With A Timer And Stopping It.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 6
Reputation:
Solved Threads: 0
Hey Guys, im trying to create a timer in c++ that starts at one, and every second the program displays the next number starting from -15, i have the start, but what i want is a breaker button... Such as while its counting, i want to be able to press either the space, enter, 1, or 0 button on the keyboard to break the timer and then display the timers current value.
Heres What I Have So Far. (Note: my script is far longer than this and so some of my #includes are necessary that you don't see)
___________________________
_________________________
If Anyone Can Help.... Please Do :-P
Thanks!
<< moderator edit: added [code][/code] tags >>
Heres What I Have So Far. (Note: my script is far longer than this and so some of my #includes are necessary that you don't see)
___________________________
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <stdlib.h> using namespace std; #include <cmath> #include <windows.h> #include <mmsystem.h> void main() { cout <<"\n\nPress 1 Then Enter To Begin: "; int anykey; cin >> anykey; if (anykey) { int timer = -15; while (timer < 45) { cout <<++timer <<", "; Sleep(1000); int key; cin >> key; switch(key) {case 1: cout <<"Your Time Was: " << timer;} }
If Anyone Can Help.... Please Do :-P
Thanks!
<< moderator edit: added [code][/code] tags >>
•
•
Join Date: Mar 2005
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Acidburn
perhaps using a while loop, it goes round until an external varible changes to 1? whilst x!= 1 or space or somethng?
Prehaps you can give me an example as to I am still confused. How do I give the user the ability to press a button while a operation (the timer counting) is going? If you or anyone else can kinda alter this script and post it, I would be sincerly greatful.
Thanks,
![]() |
Similar Threads
- Visual Basic Timer/Clock/Countdown. (Visual Basic 4 / 5 / 6)
- Problem with timer (urgent) (Visual Basic 4 / 5 / 6)
- Stopping a timer (Visual Basic 4 / 5 / 6)
- Timer Question (Visual Basic 4 / 5 / 6)
- Prevent a User From Running or Stopping a Scheduled Process in Windows XP (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: Noob question about Defining and Declaring.
- Next Thread: Help with a 5-way balanced sort merge
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





