-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcapitalize.c
41 lines (38 loc) · 1.29 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
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbin-jef <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/08 22:02:29 by sbin-jef #+# #+# */
/* Updated: 2024/05/09 17:43:18 by sbin-jef ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
char *ft_strcapitalize(char *str)
{
int x;
int capone;
x = 0;
capone = 1;
while (str[x] != '\0')
{
if ((str[x] >= 'a' && str[x] <= 'z')
|| (str[x] >= 'A' && str[x] <= 'Z'))
{
if (str[x] >= 'A' && str[x] <= 'Z')
str[x] += 32;
if (capone)
{
if (!(str[x - 1] >= '0' && str[x - 1] <= '9'))
str[x] -= 32;
capone = 0;
}
}
else
capone = 1;
x++;
}
return (str);
}