title: Reading values from CSV file into variables
body: <p>I am trying to write a simple piece of code to read values from a CSV file with a max of 100 entries into an array of structs. </p>
  
  <p>Example of a line of the CSV file:</p>
  
  <p>1,Mr,James,Quigley,Director,200000,0</p>
  
  <p>I use the following code to read in the values, but when I print out the values they are incorrect</p>
  
  <pre><code>for(i = 0; i &lt; 3; i++) /*just assuming number of entries here to demonstrate problem*/
      {
      fscanf(f, "%d,%s,%s,%s,%s,%d,%d", &amp;inArray[i].ID, inArray[i].salutation, inArray[i].firstName, inArray[i].surName, inArray[i].position, &amp;inArray[i].sal, &amp;inArray[i].deleted);
      } 
  </code></pre>
  
  <p>Then when I print out the first name, the values are all assigned to the first name:</p>
  
  <pre><code>for(j = 0; j &lt; 3; j++) /* test by printing values*/
      {
      printf("Employee name is %s\n", inArray[j].firstName);
      } 
  </code></pre>
  
  <p>Gives <code>ames,Quigley,Director,200000,0</code> and so on in that way. I am sure it's how i format the fscanf line but I can't get it to work.</p>
  
  <p>Here is my struct I'm reading into:</p>
  
  <pre><code>typedef struct Employee
      {
      int ID;
      char salutation[4];
      char firstName[21];
      char surName[31];
      char position[16];
      int sal;
      int deleted;
      } Employee;
  </code></pre>