I want it so that when the user inputs more than 5 characters, something will happen, instead of just skipping the rest.
In this code, if you type in more than 5 characters, it will only show the first 5 characters. I want to put an "if" statement here that if the user inputs more than 5 characters, it will show an error or something, and not just show the first 5 characters.
#include <iostream>
#include <iomanip>
int main()
{
using namespace std;
string nationname;
int maxchar = 5;
cout << "What is the name of your nation?\n";
cin >> setw(maxchar) >> nationname;
cout << "The name of your nation is " << nationname;
cin.ignore();
return 0;
}
Thanks!