You probably wanted:
char* result[3];
result[0] = "horse";
result[1] = "pig";
result[2] = "chicken";
What you did was wrong for two reasons.
First, you can't "assign" a string to a char array like that, you'd have to use, for example, strcpy
.
Second, your array dimension was also wrong, char array[4]
obviously won't hold "horse"
or "chicken"
, so it wouldn't work even if you corrected what I said above (it would compile, but you would be writing to memory you shouldn't be writing to).
What the corrected code does, is instead of storing the char array per se, it stores a pointer to the location in memory where "horse"
, etc., are stored. Therefore, it just stores an address, and you can then use the =
operator.