52 lines
1.5 KiB
C
52 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strcapitalize.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/18 10:52:54 by cchauvet #+# #+# */
|
|
/* Updated: 2022/07/19 12:45:26 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_is_letter(char c)
|
|
{
|
|
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
|
|
return (1);
|
|
return (0);
|
|
}
|
|
|
|
int ft_is_digit(char c)
|
|
{
|
|
if ('0' <= c && c <= '9')
|
|
return (1);
|
|
return (0);
|
|
}
|
|
|
|
char *ft_strcapitalize(char *str)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (str[i] != 0)
|
|
{
|
|
if (!(ft_is_letter(str[i - 1]) || ft_is_digit(str[i - 1])))
|
|
if (str[i] >= 'a' && str[i] <= 'z')
|
|
str[i] -= 32;
|
|
i++;
|
|
}
|
|
return (str);
|
|
}
|
|
|
|
/*
|
|
#include <stdio.h>
|
|
|
|
int main()
|
|
{
|
|
char str[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un";
|
|
printf("%s\n", ft_strcapitalize(str));
|
|
printf("Salut, Comment Tu Vas ? 42mots Quarante-Deux; Cinquante+Et+Un");
|
|
}
|
|
*/
|