#include <stdio.h>
char *ft_strupcase(char *str);
char *ft_strupcase(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] >= 'a' && str[i] <= 'z')
{
str[i] -= 32;
}
i++;
}
return (str);
}
int main(void)
{
char *test = ft_strupcase("fdfFEhk");
for (int k = 0; test[k] != '\0'; k++)
{
printf("%c", test[k]);
}
return (0);
}
The expected result is to print the string passed to the function, all in capital letters. Instead, I get a bus error. Why and how can I fix this?