hi, everyone..can i know what is the difference between cin.get() and getch()?
as what i know, this two functions can hold on the window when giving output, is that any other use of cin.get and getch?
getch is non-standard and won't work in all compilers, so you shouldn't use it.
cin.get() is standard, but it's still the wrong way to do what you want to do.
The correct way to hold the console open until the user presses enter:
1 2 3 4 5 6 7 8
#include <iostream>
#include <limits>
int main()
{
std::cout << "Press ENTER to continue..." << std::flush;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
The other methods you mentioned require you to type a character and then press enter. This method only requires you to press enter.
My compiler must be non-standard then, because if I hit enter it keeps waiting and waiting, and I have to type a character and then press enter. (It's a Microsoft compiler, bu still, it shows that cin.get() is not reliable across compilers)