Error message for String length

Hi I was wondering how to create an error message that stops user entering a string thats 20 characters long?
Put it in a do-while loop
1
2
3
4
string input;
do {
    cin >> input;
} while (cin && input.size() > 20);
Thanks :)
Topic archived. No new replies allowed.