Created
November 18, 2016 09:32
-
-
Save behitek/1ea1ef8556355bc5c3c6f11051ef93f1 to your computer and use it in GitHub Desktop.
getch in c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream > | |
#include<iomanip> | |
#include<windows.h> | |
#include<conio.h> | |
using namespace std; | |
int main() | |
{ | |
int minute = 0; | |
int second = 0; | |
int hour = 0; | |
cout << "enter to start ! "; | |
while (true) | |
{ | |
if (GetAsyncKeyState(VK_RETURN)) | |
{ | |
// int check = 0; | |
while (true) | |
{ | |
system("cls "); | |
if (second < 60) | |
{ | |
second++; | |
} | |
else if (second == 59) | |
{ | |
second = 0; | |
minute++; | |
} | |
else if (minute < 60) | |
{ | |
minute++; | |
second = 0; | |
} | |
else if (minute == 59) | |
{ | |
minute = 0; | |
hour++; | |
} | |
cout << setw(2) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << ":" << setw(2) << setfill('0') << second << endl; | |
Sleep(200); | |
char ch; | |
if(kbhit()){ | |
ch = getch(); | |
if(ch == 32) | |
do{ | |
ch = getch(); | |
}while(ch != 32); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment