Advertisement
leminhkt

noname37

Apr 5th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<conio.h>
  3. #define sz(x) x.size()
  4. using namespace std;
  5. string n;
  6. int main(){
  7.     while(true){
  8.         system("cls");
  9.         cout << "Enter your name: "; cin >> n;
  10.         bool flag = 1; int l=sz(n);
  11.         for(int j=0; j!=l; j++){
  12.             char i=n[j];
  13.             if(i<' ' || (i>' '&&i<'A') || (i>'Z'&&i<'a') || (i>'z')){
  14.                 flag = 0; break;
  15.             }
  16.         }
  17.         if(flag) break;
  18.         else{
  19.             cout << "Invalid name inputted. Please try again!";
  20.             getch();
  21.         }
  22.     }
  23.     cout<<"OK!";
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement