I’m trying to deference a char pointer to a char array inside a function:
void getword(char *word)
{
*word = "bar";
}
int main()
{
char defword[4] = "foo";
getword(defword);
printf("%s\n", defword);
return 0;
}
I would expect to get "bar" as output but I seem to get the completely unrelated string '1oo'.