Array type char[] is not assignable
You can't assign to an array, only copy to it.
Use strcpy
instead, like
strcpy(word, "Jump");
TL;DR answer : An array name is not a modifiable lvalue. So, you cannot use the assignment operator (=
) on that.
To copy the content into the array, you need to use strcpy()
from string.h
(char
array) or memcpy()
in general.
Now, to elaborate the actual reason behind the error message, quoting C11
, chapter §6.5.16, Assignment operators
assignment operator shall have a modifiable lvalue as its left operand.
and then, quoting chapter §6.3.2.1 from the same standard,
A modifiable lvalue is an lvalue that does not have array type, [....]
So, an array name is not a modifiable lvalue hence, you cannot assign anything to it. This is the reason behind the error message.