C/C++ Enter INPUT without ENTER

Hi, i'm italian, and i create a small program which simulate a PIANO, i have a question, how can i enter a value without press everytime enter, ex: i make 5 notes (do,re,mi,fa,sol) which i choise with (1,2,3,4,5), when i had choise my note, ex: 2(re), i must press Enter to confirm, do exist some another metod without press enter?

for ex:
ideclare a int choise;
scanf("%d",&coiuse);
if(choise==1)
{bla-bla}

when i press 2, i want play my sound (re) withoud confirm everytime with enter, thanks for your help.
P.S. program is in Italian, of course.
P.S.S. my program is too long 77k char (xD), and i can't add here ;)
Last edited on
There is no standard way of doing this because not all consoles are the same. To add this feature, you can try conio library for windows or curses library for *nix systems.

more information can be found here:
http://stackoverflow.com/questions/421860/c-c-capture-characters-from-standard-input-without-waiting-for-enter-to-be-pr
The standards are platform-specific, but every platform can let you get unbuffered input.

NCurses for *nix, PDCurses for Windows.

That said, if you are working on windows a simple call to SetConsoleMode() will do it.

Good luck!
closed account (3hM2Nwbp)
http://www.cplusplus.com/forum/unices/122108/
Topic archived. No new replies allowed.