title: Creating array of structure
body: <p>I have been busy with a question from a C book. The question is simple but it has some specific parts.</p>
  
  <p>I would like to ask a question about arrays.
  My question is about the best way with creating an array of a structure. The question wants these all;
  Firstly create an array of structure. Secondly, create a linked list which connects these arrays with a restp pointer.
  I want to divide my question into sub parts. First part is array of structure...
  How can I create an array of a structure. I've made a research about this. And here is my way:
  I'm creating a structure for my array of structure:</p>
  
  <pre><code>struct student{
      int id;
      struct courseList_node_s *restp;
  };
  </code></pre>
  
  <p>And my linked list for completing rest of question:</p>
  
  <pre><code>typedef struct courseList_node_s{
      char course[6];
      int credit,
          section;
      struct courseList_node_s *restp;
  }courseList_node_t;
  </code></pre>
  
  <p>I have implemented some function to handle this student schedule. 
  In my get_studentList function;
  I declared my array as this;</p>
  
  <pre><code>struct student *ansp[size];
  </code></pre>
  
  <p>And making memory allocation;</p>
  
  <pre><code>ansp[i] = malloc(sizeof(struct student));
  </code></pre>
  
  <p>And lastly assigning a value;</p>
  
  <pre><code>ansp[i]-&gt;id =id;
  </code></pre>
  
  <p>Now, my problem is while creating an array, I couldn't make it as an ordered array. For instance, the user can type 1111, 1222, 1232, and then 1011. So, my first element of array which is ansp[0] = 1011, and ansp[1] = 1111.</p>
  
  <p>I couldn't figure out. </p>
  
  <p>Can you give me an algorithm which consist these(Creating an ordered array of structure).</p>
  
  <p>Lastly, sorry for my bad English and I may made some grammatical mistakes...</p>
  
  <p>Thanks in advance.</p>