-
-
Save parzibyte/0d245594ca108e270378a27fc9d94400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
#include <string.h> | |
int esAlfanumerica(char *cadena) | |
{ | |
int i; | |
int tieneLetra = 0; | |
int tieneNumero = 0; | |
for (i = 0; i < strlen(cadena); i++) | |
{ | |
char letra = cadena[i]; | |
if (isalpha(letra)) | |
{ | |
tieneLetra = 1; | |
} | |
if (isdigit(letra)) | |
{ | |
tieneNumero = 1; | |
} | |
} | |
return tieneLetra && tieneNumero; | |
} | |
int main() | |
{ | |
// https://parzibyte.me/blog | |
char cadena[] = "Parzibyte 123"; | |
if (esAlfanumerica(cadena)) | |
{ | |
printf("Es alfanumerica\n"); | |
} | |
else | |
{ | |
printf("No es alfanumerica\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment