Good day,
I have a function ft_strupcase
which takes in a char*
, upper-cases it, and returns the parameter. The issue arose during the testing, namely using the function in a main
. The following program results in a segmentation fault:
int main()
{
char *hey = "hEy";
printf("%s\n", ft_strupcase(hey));
}
whereas this variation doesn't:
int main()
{
char hey[] = "hEy";
printf("%s\n", ft_strupcase(hey));
}
Isn't *str
and str[]
the same? Doesn't str[i]
= *(str + i)
? Why do I encounter a segfault then?