Press Enter to Continue

Press Enter to Continue

cout << "Press Enter to Continue";
cin.ignore();

or, better:

#include <limits>
cout << "Press Enter to Continue";
cin.ignore(std::numeric_limits<streamsize>::max(),'\n');

Press Enter to Continue in C

printf("Press enter to continue\n");
char enter = 0;
while (enter != '\r' && enter != '\n') { enter = getchar(); }
printf("Thank you for pressing enter\n");

Why is this Press Enter to Continue code in C++ not working?

You may have already entered "enter" after providing some data for ans. In that case, the cin.ignore() will read the "enter" and immediately return. Therefore, you would want another cin.ignore() for wait for another "enter".

How do I have a press enter to continue feature in python?

Python 2:

raw_input("Press Enter to continue...")

Python 3:

input("Press Enter to continue...")

Press ENTER to continue (Linux & C)

Please try the one below and let me know. I think that getChar is used by that scanf you wrote. A while reading a separate char can rule that out. I wrote \r in case you use other operating systems.

void setDeposit(int account, int amount)
{
printf("You have successfully transfered %d EUR to the account number %d\nPlease press ENTER to continue\n", account, amount);

char myChar = 0;
while (myChar != '\n' && myChar != '\r') {
myChar = getchar();
}
}

Detailed information about the case can be found within this thread.



Related Topics



Leave a reply



Submit