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
Incrementing Iterators: Is ++It More Efficient Than It++
Why Doesn't C++ Make the Structure Tighter
Make a File Pointer Read/Write to an In-Memory Location
Is Stl Vector Concurrent Read Thread-Safe
C++11: the Difference Between Memory_Order_Relaxed and Memory_Order_Consume
Passing Member Functions to Std::Thread
Pair<Int,Int> Pair as Key of Unordered_Map Issue
Static Member Initialization for Specialized Template Class
C++ Converting a Time String to Seconds from the Epoch
Getting an Array of Bytes Out of Windows::Storage::Streams::Ibuffer
Generic Way to Print Out Variable Name in C++
Object Oriented Programming in Haskell
How to Force a Function Not to Be Inlined
Why Are '&Array' and 'Array' Pointing to the Same Address
What Does the Comma Operator Do
C++11 Operator"" with Double Parameter
Lnk2019: Unresolved External Symbol _Main Referenced in Function _Tmaincrtstartup