2014-03-19 29 views
0

我想让玩家按任意键继续游戏,但不知道如何。这里是我到目前为止的代码:如何让玩家按任意键继续?

#include <iostream> 
#include <string> 

using namespace std; 

int main() 
{ 
    cout << "\t\tWelcome to my first game, A Hero's Journey!\n\n"; 
    char response; 
    cout << "\t\t\tPress any key to continue!: \n\n"; 
    cin >> response; 
    if (response == 
    return 0; 
} 

我目前工作的if语句,所以忽略,除非这就是我决定玩家是否已经按下的东西。

+0

可能重复的[如何模拟“按任意键继续?”](http://stackoverflow.com/questions/1449324/how-to-simulate-press-any-key-to-continue) – Brian

回答

1

由于cin总是等待输入,因此不需要if条件。如果你需要用户输入一个特定的密钥,那么你需要一个if条件来检查它。

+0

谢谢对于这些信息,我曾经这么做过,但这些年来变得非常生疏。 –

相关问题