YAMILDIAZ

validar nombre

Jun 13th, 2024
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | Source Code | 0 0
  1.  
  2. #include <ctype.h> ///Para las funciones de clasificación de caracteres, como isalpha.
  3.  
  4. bool Persona::caracterValido(std::string &cad){
  5.     for(int i = 0; i < cad.size(); i++){//Recorre cada carácter de la cadena desde el índice 0 hasta cad.size()
  6.         if(!isalpha(cad[i]) && cad[i] != ' '){//Si se encuentra un carácter no alfabético, la función devuelve false
  7.             return false;
  8.         }
  9.     }
  10.     return true;///Si el bucle completa la iteración sin encontrar caracteres no alfabéticos, la función devuelve true.
  11. }
Advertisement
Add Comment
Please, Sign In to add comment