title: C Reading input into an char array in loop
body: <p>I am reading input from <code>stdin</code> e.g. name of car, type of car.</p>
  
  <p>The problem I am facing is, if I entered number of cars 2 and I take
  input in loop, the second value is overwritten to the first value via <code>scanf</code>.</p>
  
  <p>Enter number of cars:2</p>
  
  <p>Enter name of column :chevy</p>
  
  <p>Type of car available can be electric,gas - Enter type of car :gas</p>
  
  <p>Enter name of column :chevy2</p>
  
  <p>Type of car available can be electric,gas - Enter type of car :electric</p>
  
  <p>now if I print all I see is electric</p>
  
  <pre><code> #include &lt;stdio.h&gt;
  
      int main(int argc, char *argv[])
      {
          setbuf(stdout, NULL);
          int carNum;
          int i;
  
          char carName[50];
          char carType[200];
  
          printf("\nEnter number of cars:");
          scanf("%d",&amp;carNum);
          for(i=0;i&lt;carNum;i++)
           {
               printf("\nEnter name of car :");
       scanf("%s", &amp;carName[i]);
  
       printf("\nType of car available can be electric,gas - Enter type of car %d: ");                             
       scanf("%s", &amp;carType[i]);
           }
  
           for(i=0;i&lt;carNum;i++)
           {
  
               printf("\nName of car %d: ",i+1);
               printf("\n%s", &amp;carName[i]);
  
  
               printf("\nType of car %d: ",i+1);
               printf("\n%c", &amp;carType[i]);
           }  
  
  
          return 0;
      }
  </code></pre>