I have C++ code that look like this:
void Typewriter(string strOk) {
for (unsigned int x = 0; x < strOk.length(); x++) {
cout << strOk[x];
Sleep(50);
}
cout << endl;
}
int main() {
Typewriter("OK, Hello. This is a first thingy. IDK.");
Typewriter("This is the second line, also the second call to the function");
cin.get();
Typewriter("You pressed Enter! [Enter] next page");
cin.get();
Typewriter("Haha, no next page. Now, cya!");
return 0;
}
It works just fine, except while cin.get()
is waiting for an Enter keypress, the user can enter other characters and they will show up in the console.. It kind of acts like cin
but executes the next statement when Enter is pressed. How do I restrict keyboard presses from being shown in the console and only react when Enter is pressed?