title: array of pointer stores strings in c
body: <p>i am going to Write a program that stores strings and print the last two strings
  (i shoulde Use array of pointers).</p>
  
  <p>this is my code</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include &lt;string.h&gt;
  main()
  {
      char*arr[10];
      char student_name[20];
      int i,j;
  
      for(i=0;i&lt;10;i++) {
          printf("Enter the name of student %d : ",(i+1));
          scanf("%s",student_name);
          arr[i]=student_name;
      }
  
      for(j=7;j&lt;10;j++) {
          printf("the name of student %d : %s\n",(j+1),arr[j]);
      }
  }
  </code></pre>
  
  <p>it just stores the last string and prints it </p>
  
  <p>this is the samle run</p>
  
  <pre><code>Enter the name 1 : qqq
  Enter the name 2 : www
  Enter the name 3 : eee
  Enter the name 4 : rrr
  Enter the name 5 : ttt
  Enter the name 6 : yyy
  Enter the name 7 : uuu
  Enter the name 8 : ii
  Enter the name 9 : ioo
  Enter the name 10 : ppp
  the name 9 : ppp
  the name 10 : ppp
  </code></pre>
  
  <p>what is my mistake?</p>
  
  <p>also if i replase </p>
  
  <pre><code>arr[i]=student_name;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>strcpy(arr[i], student_name);
  </code></pre>
  
  <p>the sumple run will be</p>
  
  <pre><code>Enter the name 1 : ddf
  Segmentation fault (core dumped)
  </code></pre>