Is it possible to do so when you make a input you don't need to push enter?
like "1+1="
then you just press 2 and it outputs "right!" for an example
if it works, then how?
Is it possible to do so when you make a input you don't need to push enter?
like "1+1="
then you just press 2 and it outputs "right!" for an example
if it works, then how?
depends on the implementation. what OS/compiler are you using?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
#include "conio.h" --non standard
getch(); //doesnt echo to the screen
getche(); // echos to the screen
"Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
-- Cowper
Operating Systems=Slackware Linux 9.1,Windows 98/Xp
Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)
You may teach a person from now until doom's day, but that person will only know what he learns himself.
Now I know what doesn't work.
A problem is understood by solving it, not by pondering it.
For a bit of humor check out xkcd web comic http://xkcd.com/235/
I'm using Dev-C++,Originally Posted by Sebastiani
It didn't worked manofsteel >.< I need a code so I can make an input without pressing ENTER, thanks for help anybody
Last edited by Noxir; 08-06-2004 at 05:24 PM.
They do, echo means that it shows what you pressed. If you use getch(), then you wont see the input, just the "Your right!", aslong as you put the if statement after checking it, that is. getche() will show what you typed, so it is most likely what you want. To get them to work, use it like declaring a variable:
Code:input=getche();
Now the problem is, that when I start this program the "1+1=" comes after I've pressed a button, any ideas? x_XCode:#include <iostream.h> #include <conio.h> int main () { int x; x=getche(); cout << "1+1="; cin>>x; system("PAUSE"); }
getche() and getch() act like their own input, so you dont need cinCode:#include <iostream.h> #include <conio.h> int main () { int x; cout << "1+1="; x=getche(); system("PAUSE"); return 0; }
By setting x equal to getch, it runs the getch function and places whatever the result is (i.e. the button you pressed, in x).
Thnks all