2010-08-21 25 views

回答

5

嘗試getline

string s; 
getline(cin, s); 
2

回車鍵是比較容易的情況下,作爲邁赫達德回答,只是從std::cin讀的東西。

如果您想終止不同的按鍵,例如,退出任何按鍵,您可以使用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"); 
相關問題