tags:

views:

82

answers:

2

Anyone knows this tip?

+4  A: 

Try getline:

string s;
getline(cin, s);
Mehrdad Afshari
+2  A: 

Return key is the easy case, as Mehrdad answered, just read something from std::cin.

If you want to terminate on a different key press, for example, exit on any key, you can use a couple non-standard calls in conio.h.

#include <conio.h>

// wait for any key press
while (!kbhit()) { }

// wait for q key press
while (!kbhit() || getch() != q) { }

// wait for any key press on windows
system("pause");
Inverse