How can I make an error checking of outbounding the charlength when using std::cin?
char _charArr[21];
bool inputNotVerified = true;
while (inputNotVerified) {
cout << "input a string no more than 20 chars: ";
cin >> _charArr;
// if the errorchecking works the boolean should be set to false
}
As stated in the comment above - the only thing that can break the loop is when the input is correct - that is no more than 20 characters. But how do i implement it?
I have tried to make a condition out of strlen(_charArr) but without success.
std::stringand check its length.