#include <stdio.h>
#include <string.h>
char *ft_strcapitalize(char *str)
{
int index;
index = 0;
while (str[index] != '\0')
{
if ((str[index] >= 'a' && str[index] <= 'z')
&& (index == 0 || str[index - 1] == ' '
|| str[index -1] == '+' || str[index -1] == '-'))
{
str[index] = str[index] - 32;
}
index++;
}
return (str);
}
int main() {
char str[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un qwdlh280++s7ed 3j;b3";
char d[10];
ft_strcapitalize(str);
printf("%s\n", str);
strcpy(d, str);
printf("%s\n", d);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: