Press Enter to Continue

前端 未结 7 1893
南笙
南笙 2020-12-05 02:08

This doesn\'t work:

string temp;
cout << \"Press Enter to Continue\";
cin >> temp;
7条回答
  •  执念已碎
    2020-12-05 02:44

    Try:

    char temp;
    cin.get(temp);
    

    or, better yet:

    char temp = 'x';
    while (temp != '\n')
        cin.get(temp);
    

    I think the string input will wait until you enter real characters, not just a newline.

提交回复
热议问题