Hello, I'm still a huge beginner in C++ and while i spent hours trying to find a solution to this problem i came to this forum pretty often and I thought it'd be a good idea if I try to ask about my problem. (If you notice anything that can be done better I'd be more than happy to hear an criticism, advice, or lesson about coding). I just wanted to try a little project on my own outside of my C++ class and I wanted to make a timer for myself (since i always end up losing my sense of time on the computer haha), Everything was going fine until i found the urge to make a Snooze and shutdown available while my program continuously plays a beep (Sort of like an alarm clock). Obviously Im stuck at being able to input something while the beep is going on. I don't even know if its possible since If i do cin>> in the loop itll only beep once before it waits for input and if i dont itll just never stop looping. Line 40 and down is me trying to use getch() (I read up about inputting without the prompting of enter, so i was hoping it would somehow work) but it doesnt work the way I want it to.
Edit: i use dev-cpp btw :P (If theres a better program/compiler out there id also be glad to hear about that.)
#include <iostream>
#include <time.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main()
{
int num; //number being inputted by the user for the time.
int input; //number inputted by the user in order to make his selection.
cout<<"Please choose what you would like your countdown in.\n"; //Whether the user wants their time in minutes or seconds.
cout<<"1.Seconds\n";
cout<<"2.Minutes\n";
cin>>input; //The user inputs his selection for the countdown.
Beep(1450,300);
system ( "cls" );
switch (input){
case 1: //The user has chosen his countdown in seconds (1000 ms countdown)
cout<<"Please input the number of seconds to initiate the countdown.\n"; //Input by the user
cin>>num;
system ( "cls" );
if (num>0) //If the user follows the instructions correctly.
{
while (num>0) //Literal countdown sequence
{
cout<<num<<"\n";
num--;
Beep(1450,100);
Sleep(900);
system ( "cls" );
}
while (num==0) // When the countdown reaches 0
{
cout<<"*ALARM*\n";
Beep(1450,100);
num = getch();
if (num!=0)
{cout<<"Shutting down alarm...";
Sleep(3000);
return 0;
}