-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcapitalize.c
37 lines (35 loc) · 1.28 KB
/
ft_strcapitalize.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nkuzminy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 12:59:08 by nkuzminy #+# #+# */
/* Updated: 2022/07/21 17:39:03 by nkuzminy ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcapitalize(char *str)
{
int i;
int l;
i = 0;
l = 0;
while (str[i] != '\0')
{
if (l == 0 && (str[i] >= 'a' && str[i] <= 'z'))
{
str[i] -= 32;
l++;
}
else if (l > 0 && (str[i] >= 'A' && str[i] <= 'Z'))
str[i] += 32;
else if ((str[i] < '0') || (str[i] > '9' && str[i] < 'A')
|| (str[i] > 'Z' && str[i] < 'a') || (str[i] > 'z'))
l = 0;
else
l++;
i++;
}
return (str);
}