first commit
This commit is contained in:
40
ended/C02/ex09/ft_strcapitalize.c
Normal file
40
ended/C02/ex09/ft_strcapitalize.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcapitalize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 19:09:13 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 19:09:17 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcapitalize(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
if (str[i] >= 'a' && str[i] <= 'z')
|
||||
{
|
||||
if (str[i - 1] <= 47 || str[i - 1] == 0
|
||||
|| (str[i - 1] >= 58 && str[i - 1] <= 64)
|
||||
|| (str[i - 1] >= 91 && str[i - 1] <= 96)
|
||||
|| (str[i - 1] >= 123 && str[i - 1] <= 126))
|
||||
{
|
||||
str[i] -= 32;
|
||||
}
|
||||
}
|
||||
if (str[i] >= 'A' && str[i] <= 'Z')
|
||||
{
|
||||
if (str[i - 1] > 47)
|
||||
{
|
||||
str[i] += 32;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
Reference in New Issue
Block a user