title: reading variables in struct type in for loop
body: <p>I'w writing piece of code and I should read variables from for loop:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  #define NumOfStudents 100
  #define NumOfCourses 15
  
  struct Student{
    int stdnum, FieldCode, age;
    double average, res[NumOfCourses];
    char name[20];          //First and Last name length                                                                                                                          
  };
  
  int main(){
    struct Student students[NumOfStudents];
    int i;
    cout &lt;&lt; "\tNAME || STUDENT-NUMBER || FIELD-CODE || AGE";
    for(i=0; i&lt;NumOfStudents; i++){
      cout &lt;&lt; "\nSTUDENT #" &lt;&lt; i+1 &lt;&lt; ": ";
      cin &gt;&gt; students[i].name[20] &gt;&gt; students[i].stdnum &gt;&gt; students[i].FieldCode &gt;&gt; students[i].age;                                                                            
      //    cin &gt;&gt; students[i].name[20];                                                                                                                                          
    }
  }
  </code></pre>
  
  <p>EDIT:
  output is:</p>
  
  <pre><code>./st 
      NAME || STUDENT-NUMBER || FIELD-CODE || AGE
  STUDENT #1: test
  
  STUDENT #2: 
  STUDENT #3: 
  STUDENT #4:
  .
  .
  .
  STUDENT #100:
  </code></pre>
  
  <p>I can just enter name of first student and loop doesn't work correctly
  what is the problem?</p>