Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 15, 2022 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/0d245594ca108e270378a27fc9d94400 to your computer and use it in GitHub Desktop.
Save parzibyte/0d245594ca108e270378a27fc9d94400 to your computer and use it in GitHub Desktop.
#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