-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcapitalize.c
executable file
·42 lines (39 loc) · 1.35 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
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kbensado <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/10/16 13:36:14 by kbensado #+# #+# */
/* Updated: 2015/12/28 12:21:24 by kbensado ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strcapitalize(char *str)
{
int i;
i = 0;
while (str[i++])
{
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
}
i = 1;
if (str[0] >= 'a' && str[i] <= 'z')
str[0] -= 32;
while (str[i] != '\0')
{
if (str[i] >= 'a' && str[i] <= 'z')
{
if ((str[i - 1] <= 96 && str[i - 1] >= 91) ||
(str[i - 1] <= 64 && str[i - 1] >= 58) ||
str[i - 1] >= 123 || str[i - 1] <= 47)
str[i] -= 32;
i++;
}
else
i++;
}
return (str);
}