0

Is it possible to make my code run without having to press Enter on my IDE? For example: if I'm making a calculator and I want the calculations to be made as soon as I press "=" after typing the numbers and the operator? Say I wanted to add two numbers: can it calculate automatically as soon as I write "2+3=" without having to press Enter?

7th Aug 2016, 7:03 AM
jigoku_tenshi
5 Antworten
+ 2
by using getche() function
12th Aug 2016, 5:43 PM
SUCHIT YADAV
SUCHIT YADAV - avatar
+ 1
int a; while(cin>>a != '=') { //some code }
7th Aug 2016, 8:47 AM
Hooman
Hooman - avatar
+ 1
I tried using getche() but my IDE (Xcode) doesn't accept it and switches it to getchar(). Also, could I use getche() for strings or is there another function for that?
13th Aug 2016, 12:36 AM
jigoku_tenshi
0
@Hooman: The code contains at least one severe error.
7th Aug 2016, 8:00 PM
Stefan
Stefan - avatar
0
char ch=getche(); //also include conio.h //only for character
13th Aug 2016, 4:44 AM
SUCHIT YADAV
SUCHIT YADAV - avatar