Structures in C programming (initializing statements) -
i error message "error: incompatible types when assigning type ‘char[10]’ type ‘char *’ ", when trying initialize name in following structure:
#include <stdio.h> struct info { char name[10]; int years; }; int main(void){ struct info b; b.name = "michael"; b.years = 19; return 0 ;}
since you're trying initialize struct, away with:
struct info b = {"michael", 19}; c makes distinction between initialization , assignment (even though use same operator). arrays cannot assigned, (memcpy or similar must used instead) data can come existence value, initializer specifies.
Comments
Post a Comment