在我之前的问题中,我得到了这个答案,让如果用户在国家名称中输入超过5个字符,它将输出错误信息。
我希望它在输出错误后能循环回到“cout << what is the name…”。谢谢!有人在我的先前问题的评论中回答了如何做,但我无法使其正常工作/不知道在我的代码中如何或在哪里放置它。
#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 << what is the name…”。谢谢!有人在我的先前问题的评论中回答了如何做,但我无法使其正常工作/不知道在我的代码中如何或在哪里放置它。