Little program

How to when i press number 1 on keyboard to do something in program, but not to press 1 then enter ???

e.g.

If you want to print press 1
if you want to divide press 2....
The istream object has a member function called "get()" that can do this: http://www.cplusplus.com/reference/istream/istream/get/ std::cin is an istream object. This function does not skip whitespace and it will take the next input from the buffer even if you did not want it to be there.
you can also include <conio.h> or <windows.h> and use the function 'getch()' like this:

char c = getch();

this waits for a keypress, and the minute one is made, it stores it in the variable c.
Topic archived. No new replies allowed.