when assigning a string to a member defined as char name 20 it will not compile the input string

You cannot assign an array in C.

You could strncpy to write to it, for instance:

strncpy(unionVar.name, "Bill can code", sizeof(unionVar.name) - 1);
unionVar.name[sizeof(unionVar.name) - 1] = '\0';

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top