title: In C, how to print all the values in struct by using linked-list, while this struct is nested?
body: <p>I have create two struct and two variables n1 and n2, here is the result when runnig code below:</p>
  <p>10-nick-90.500000</p>
  <p>20-wilson-100.500000.</p>
  <p>What I want:</p>
  <p>1.take elemtype variable values and put them into struct LNODE.</p>
  <p>2.print values by using printlist(LNDOE* head).</p>
  <p>Please help me.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef struct elemtype{
      int no;
      char* name;
      double score;
  }elemtype;
  
  typedef struct tagnode{
      elemtype data;
      struct tagnode* next;
  }LNODE;
  
  elemtype* print_elemtype(elemtype* data_to_print){
      elemtype* p = data_to_print;
      if ( p != NULL){
          printf(&quot;%d-%s-%lf&quot;, p-&gt;no,p-&gt;name,p-&gt;score);
      }
      printf(&quot;\n&quot;);
      return NULL;
  }
  
  void creat_link(LNODE** head, int n, void (*input)(elemtype*)){
      LNODE* s;
      *head = (LNODE*)malloc(sizeof(LNODE));
      (*head)-&gt;next = NULL;
      for(;n&gt;0;n--){
          s = (LNODE*)malloc(sizeof(LNODE));
          input(&amp;(s-&gt;data));
          s-&gt;next = (*head)-&gt;next;
          (*head)-&gt;next = s;
      }
  }
  
  
  
  int main()
  {
      elemtype* n1 = malloc(sizeof(elemtype));
      elemtype* n2 = malloc(sizeof(elemtype));
      n1-&gt;name = &quot;nick&quot;;
      n1-&gt;no = 10;
      n1-&gt;score = 90.5;
      n2-&gt;name = &quot;wilson&quot;;
      n2-&gt;no = 20;
      n2-&gt;score = 100.5;
  
      elemtype** s1,**s2;
      s1 = &amp;n1;
      s2 = &amp;n2;
  
      print_elemtype(n1);
      print_elemtype(n2);
  
      
      
      free(n1);
      free(n2);
      n1 = NULL;
      n2 = NULL;
  }
  </code></pre>