title: storing a string in linked list in c
body: <p>i am very new in programming and its my 2nd semester in my college an dour teacher teach us about linked list and malloc function where we can make a node dynamically and increase or decrease its size . our teacher teach us how to store a integer value in list like this</p>
  
  <pre><code>struct node
  { 
    int num;
    struct node *next;
  }head;
  </code></pre>
  
  <p>but i want to store a string say "name" of students in linked list instead of integer .. so i want to know how to do this ..
  i write this code for that  </p>
  
  <hr>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  struct node
  {
      char name[20];
      int age;
      struct node *next;
  };
  //
  void addatbegin(struct node **q,char name [20],int age)
  {
      struct node *r;
      r=(struct node *)malloc(sizeof(struct node));
      r-&gt;name=name;
      r-&gt;age=age;
      r-&gt;next=*q;
      *q=r;
  }
  //
  void addatend(struct node **q,char name[20],int age)
  {
      struct node *temp,*r;
      if(*q==NULL)
      {
          temp=(struct node *)malloc(sizeof(struct node));
      temp-&gt;name=name;
      temp-&gt;age=age;
      temp-&gt;next=NULL;
      *q=temp;
      }
  else {
      temp=*q;
      while(temp-&gt;next!=NULL)
      {
          temp=temp-&gt;next;
      }
  r=(struct node *)malloc(sizeof(struct node));
  r-&gt;name=name;
  r-&gt;age=age;
  r-&gt;next=NULL;
  temp-&gt;next=r;
  }}
  
  void main()
  {
      struct node *head;
      int age,ch;
      char name[20];
      head=NULL;
      while(1)
      {
          printf("***** MENU ****** \n");
          printf("1.Add at Begining of List\n");
          printf("2.Add at End of List\n");
          printf("3.Print the list\n");
          printf("4.Exit\n \n");
          printf("Enter Your choice:- ");
          scanf(" %d",&amp;ch);
          switch(ch)
          {
              case1:printf("Enter Name:- ");
              scanf(" %s",name);
                          printf("Enter Age:- ");
                          scanf(" %d",&amp;age);
   addatbegin(&amp;head,name,age);
   break;
          }
  getch(); }}
  </code></pre>
  
  <hr>
  
  <p>but its shwoing error lvalue missing                        </p>