Char array in a struct – incompatible assignment? [duplicate]

This has nothing to do with structs – arrays in C are not assignable:

char a[20];
a = "foo";   // error

you need to use strcpy:

strcpy( a, "foo" );

or in your code:

strcpy( sara.first, "Sara" );

Leave a Comment