title: How to assign values to a list in C
body: <p>I have this list and I'm writing a function to ask the user to add the info: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #define MAXTAB 40
  #define MAXSTR 25
  
  typedef enum {Prob, Impr, Terr, Jail} Type;
  
  typedef struct {
      int pos;
      char name[MAXSTR+1];
      char owner[MAXSTR+1];
      int price;
      Type info;
  } Casella;
  
  struct lista {
      Casella Tab;
      struct lista *node;
  };
  
  typedef struct lista Lista;
  
  void printElement (Lista *);
  void printTab (Lista *);
  Lista * initializeTab (Lista *, int);
  Lista * addInfo (Lista*);
  
  int main()
  {
      Lista *list = NULL;
      int i;
  
      for (i=0; i&lt;MAXTAB; i++){
          list = initializeTab(list, i);
      }
  
      printTab(list);
  
      return 0;
  }
  
  void printElement (Lista *l){
  
      printf("Position: %d\n", l-&gt;Tab.pos);
  
  }
  
  void printTab (Lista *l){
  
      while(l!=NULL){
          printElement(l);
          l=l-&gt;node;
      }
  
  }
  
  Lista * initializeTab (Lista *l, int x){
  
      Lista *newTab = NULL;
  
      newTab = (Lista*)malloc(sizeof(Lista));
  
      newTab-&gt;Tab.pos = x;
      newTab-&gt;node = l;
  
      return newTab;
  
  }
  
  Lista * addInfo (Lista *l){
      Lista *list = NULL;
      list-&gt;Tab.name = (char*)malloc(MAXSTR * sizeof(char));
      return list;
  }`
  </code></pre>
  
  <p>In the function "addInfo", I try to allocate memory for the Tab name, but it tells me I can't assign type array char to that. My question is, how do I allocate memory for various list elements? Like I want to allocate memory for the list.name, then list.owner, list.pos etc... and then assign values to them.</p>