-
Notifications
You must be signed in to change notification settings - Fork 0
isalpha
Marcos edited this page Sep 30, 2024
·
2 revisions
La función isalpha comprueba si el carácter pasado como argumento es una letra del alfabeto, ya sea en mayúsculas o minúsculas.
ISALPHA(3) (simplified)
NAME
isalpha -- alphabetic character test
SYNOPSIS
int isalpha(int c)
DECRIPTION
The isalpha() function tests for any character for which isupper(3) or islower(3) is true. The value of the argument must be resprensentable as an unsigned char or the value of EOF.
RETURN VALUES
The isalpha() function return zero if the character tests false and returns non-zero if the character tests true.
La función isalpha() evalúa si el valor entero pasado como argumento corresponde a un carácter alfabético. En otras palabras, verifica si el carácter pertenece al conjunto de letras en mayúsculas o minúsculas (de la 'A' a la 'Z' o de la 'a' a la 'z'). Si el valor es un carácter alfabético, la función devuelve un valor distinto de cero; de lo contrario, devuelve 0.
Aquí te muestro mi implementación de la función ft_isalpha en mi proyecto de Libft.
int ft_isalpha(int c)
{
return ((c >= 65 && c <= 90) || (c >= 97 && c <= 122));
}El siguiente código es un ejemplo de cómo puedes probar la función 'ft_isalpha()':
#include <stdio.h>
int ft_isalpha(int c);
int main(void)
{
char test1 = 'A';
char test2 = 'z';
char test3 = '1';
printf("Test con 'A': %d\n", ft_isalpha(test1)); // Debe devolver 1
printf("Test con 'z': %d\n", ft_isalpha(test2)); // Debe devolver 1
printf("Test con '1': %d\n", ft_isalpha(test3)); // Debe devolver 0
return 0;
}