-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_isalpha.c
65 lines (56 loc) · 1.81 KB
/
ft_isalpha.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yuske <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 03:15:45 by yfurutat #+# #+# */
/* Updated: 2022/11/18 15:45:36 by yuske ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// int main()
// {
// printf("%c\n", ft_isalpha('a'));
// printf("%c\n", ft_isalpha('1'));
// printf("%c\n", ft_isalpha('Z'));
// printf("%c\n", ft_isalpha('='));
// return (0);
// }
//1
// int ft_isalpha(int ch)
// {
// if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
// return (1);
// else
// return (0);
// }
//2 magic nbr
// int ft_isalpha(int ch)
// {
// return ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122));
// }
//3 hexadicimal
// int ft_isalpha(int ch)
// {
// return ((ch >= 0x41 && ch <= 0x5a) || (ch >= 0x61 && ch <= 0x7a));
// }
//4 most readable?
// int ft_isupper(int ch)
// {
// return (ch >= 'A' && ch <= 'Z');
// }
// int ft_islower(int ch)
// {
// return (ch >= 'a' && ch <= 'z');
// }
// int ft_isalpha(int ch)
// {
// return (ft_isupper(ch) || ft_islower(ch));
// }
//5 simplest + fastest?
int ft_isalpha(int ch)
{
return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'));
}