在我之前的问题中,我得到了这个答案,以便如果用户在国名中输入5个以上的字符,它会输出一个错误。C++ - 如何在用户输入后循环回来?
#include <iostream>
#include <iomanip>
int main()
{
using namespace std;
const int maxchar = 5;
string nationname;
cout << "What is the name of your nation?" << endl;
cin >> nationname;
if (nationname.size() > maxchar)
{
cout << "The input is too long." << endl;
return 1;
}
}
我想它,这样它会循环回“COUT < <名称是什么?”之后输出错误。
谢谢!
有人回答我的上一个问题如何在评论中,但我没有得到它的工作/我不知道如何或在哪里把它放在我的代码。
谢谢!我终于搞定了。 – Leroterr1 2013-04-22 02:45:34