Quote:
Originally Posted by Bonny
Hello. I am a newb programmer of C++. I use KDevelop 3.5.1 gcc++.
I am interested in creating a simple program that will allow the user to press a key and, without pressing enter, the computer to record that key (and use it).
I know the way in normal C++ is: 'int a=getch();' and it works, but this doesn't work on KDevelop...
Does anyone have any suggestions?
Thank you in advance!
|
You have to add this lines:
in the main() {
char ch;
system("stty -echo"); // supress echo
system("stty cbreak"); // go to RAW mode
// ch = getchar(); // or something like that
while ((ch = getchar()) != 'q') {
;; // DO what you want
}
system ("stty echo"); // Make echo work
system("stty -cbreak");// go to COOKED mode
}
ALL "C" kompilers supported.
// Do not brake it with Crtl-C. If you did so restore echo so
"stty echo" in blind mode. Echo supressed.
It works on all Linux systems, always. Do'nt forget to
include <stdlib.h>
Have sombody any Idea how to make it in Java?