-2
實時檢查字符,我需要在我的循環中實時獲取角色並按條件進行檢查。如果用戶按除輸入外的任何內容,程序工作正常。誰能幫我 ?謝謝 !C++如何通過_getch()
while (read != '\n')
{
cout << "Enter character:\n";
read = _getwch();
if (read == '\n') {
cout << "You pressed : ENTER\n";
}
else {
cout << "Your character is: \"" << read << "\"\n\n";
read = '\0';
}
}
_kbhit(),也許。 – 2014-12-13 12:46:56
當您按ENTER鍵時會發生什麼? – zvone 2014-12-13 15:15:35