Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- using namespace std;
- bool validate(string name)
- {
- bool flag = true;
- for(int sub = 0; sub < name.length(); sub++)
- {
- if(!isalpha(name[sub]))
- {
- cout << "Your name cannot contain: " << name[sub] << endl;
- flag = false;
- }
- }
- return flag;
- }
- int main()
- {
- string input;
- cout << "What's your first name?\n";
- cin >> input;
- if (validate(input))
- {
- cout << "Valid name.\n";
- }
- else
- cout << "Invalid name.\n";
- }
Add Comment
Please, Sign In to add comment