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

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -