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)
___________________________
#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
tags >>