Quote:
>My complier (g++)
g++ is a C++ compiler, so comp.lang.c++ might have been a more
appropriate forum.
Quote:
> is giving me:
>"incompatible types in assignment of const char* to char[64]"
>Why?
Presumably, you have something like
char carray[64];
...
carray = "hello";
You can't assign to arrays, but you can assign to their constituent
elements. So
int iarray[64];
iarray = 3; /* assignment to array, not allowed */
is illegal, but
int iarray[64];
iarray[0] = 3; /* assignment to element, allowed */
is fine.
Quote:
>How is this differing from :
>char[64] = "hello";
If you mean something like
char carray[64] = "hello";
the difference is that this is an initialisation, not an assignment.
As its name suggests, initialisation sets the _initial_ value for an
object.
int i = 5; /* defines i, and initialises it to 5 */
int j; /* defines j, but does not initialise it */
j = 3; /* assigns 3 to j (not an initialisation) */
Other types of array can be initialised too, e.g.
int iarray[64] = { 1, 2, 3, 4, 5 };
but, as with character arrays, assignment
iarray = { 1, 2, 3, 4, 5 };
is illegal.
-- Mat.