title: How to accept character array input into a structure in C?
body: <p>I've got this structure, a simple one that holds student name and marks. When I'm trying to read user input into the name(char array), I get a warning indicating something on the lines of : </p>
  
  <pre><code>format %s expects char *, but has char*[20]
  </code></pre>
  
  <p>I know this is because <code>char arrays</code> cannot be assigned in C, so <code>strcpy</code> has to be used. This <a href="https://stackoverflow.com/questions/1292586/char-array-in-a-struct-incompatible-assignment">question</a> on SO has a good reasoning. However,how do I fix the warning in my program? Don't think I can use strcpy here.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  
  typedef struct _student
  {
      char name[20];
      unsigned int marks;
  } student;
  
  
  void read_list(student list[], int SIZE);
  void print_list(student list[], int SIZE);
  
  int main()
  {
      const int SIZE=3;
      student list[SIZE];
  
      //function to enter student info.
      read_list(list, SIZE);
      //function to print student info
      print_list(list, SIZE);
      return 0;
  }
  
  void read_list(student list[], int SIZE)
  {
      int i;
      char nm[20];
      for (i=0;i&lt;SIZE;i++)
      {
          printf("\n Please enter name for student %d\n", i);
          scanf("%s",&amp;list[i].name);
  
          printf("\n Please enter marks for student %d\n", i);
          scanf("%u", &amp;list[i].marks);
      }
  
  }
  
  void print_list(student list[], int SIZE)
  {
      int i;
      printf("\t STUDENT NAME  STUDENT MARKS\t \n");
  
      for(i=0;i&lt;SIZE;i++)
      {
          printf("\t %s \t %u\n", list[i].name, list[i].marks);   
      }
  }
  </code></pre>
  
  <p>The program does give a correct output, but the warning remains.</p>