void    ft_strlowcase(char *str)
{
        int     i;

        i = 0;
        while (str[i] != '\0')
        {
                if ((str[i] >= 'A' && str[i] <= 'Z'))
                {
                        str[i] += 32;
                }
                i++;
        }
}

char    *ft_strcapitalize(char *str)
{
        int     i;
        int     start_of_word;

        i = 0;
        start_of_word = 1;
        while (str[i] != '\0'){   
    ft_strlowcase(str);
        {
                if (str[i] >= '0' && str[i] <= '9')
                {
                        start_of_word = 0;
                }
                else if ((str[i] >= 'a' && str[i] <= 'z') && start_of_word == 1)
                {
                    str[i] -= 32;
                    start_of_word = 0;
                }
                else if (!(str[i] >= 'a' && str[i] <= 'z')
                        && !(str[i] >= '0' && str[i] <= '9'))
                {
                        start_of_word = 1;
                }
                i++;
        }
        }
        return (str);
}

#include <stdio.h>
int main()
{
        char x[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un";
        printf("%s \n", x);
        ft_strcapitalize(x);
        printf("%s", x);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: