Omnimaga
General Discussion => Technology and Development => Computer Programming => Topic started by: hellninjas on March 25, 2013, 08:26:52 pm
-
I've read up a bit through google.
getch(); from the <conio.h> seems to have a lot of hits, yet i'm not sure how to use it :c
Or are there other ways?
I'd mostly like to pause the program and wait for a keystroke, then check if the user pressed "y" or "n".
-
take a look at std::cin (http://www.cplusplus.com/reference/iostream/cin/).
-
getch() is exactly the right thing you need. It waits for a keypress and returns the character that was typed.
#include <conio.h>
...
char c;
do {
c = getch();
} while (c != 'y' && c != 'n');
if (c == 'y'){
do stuff;
} else {
do something else;
}