diff --git a/ex09/ft_strcapitalize.c b/ex09/ft_strcapitalize.c new file mode 100644 index 0000000..b54c9a5 --- /dev/null +++ b/ex09/ft_strcapitalize.c @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcapitalize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tischmid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/03/19 11:27:43 by tischmid #+# #+# */ +/* Updated: 2023/03/19 11:44:36 by tischmid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcapitalize(char *str) +{ + int i; + int inside_word; + int is_alpha; + int is_numeric; + char c; + + inside_word = 0; + i = -1; + while (str[++i] != '\0') + { + c = str[i]; + is_alpha = (c | 32) >= 'a' && (c | 32) <= 'z'; + is_numeric = c >= '0' && c <= '9'; + if (!inside_word && (is_alpha || is_numeric)) + { + inside_word = 1; + if (is_alpha) + str[i] = str[i] & 95; + } + else if (inside_word && (is_alpha || is_numeric)) + str[i] = str[i] | 32; + else + inside_word = 0; + } + return (str); +} + +/* //// +#include + +int main(void) +{ + char s1[] = "hallo mein name ist timo und das ist ein 13371G3R TEXT hier"; + char *s2; + s2 = ft_strcapitalize(s1); + printf("%s\n", s2); + return (0); +} +*/ ////