title: Parse char array in c
body: <p>I am trying using C to parse this character array: "Smith C. John, 103, 10, 10, 10" (without quotes).</p>
  
  <p>I already tried this:</p>
  
  <pre><code>int group = 0, mark1 = 0, mark2 = 0, mark3 = 0; 
  
  char input[100];
  char lastName[100];
  char firstName[100];
  char initial[100];
  int n;
  
  fgets(input, 1000, sourceFile);
  n = sscanf(input,"%s %s. %s, %d, %d, %d, %d\n", lastName, initial, firstName, group, mark1, mark2, mark3);
  </code></pre>
  
  <p>This code reads correctly the last name and the initial (with the dot unfortunately) only.
  The values should be like this:</p>
  
  <pre><code>lastName = Smith
  initial = C
  firstName = John
  group = 103
  mark1 = 10
  mark2 = 10
  mark3 = 10
  </code></pre>
  
  <p>Please help me!
  Thank you!</p>
  
  <p>Changed to this to work:</p>
  
  <pre><code>int i = 1, group = 0;
  float mark1 = 0, mark2 = 0, mark3 = 0; 
  char input[100];
  char lastName[100];
  char firstName[100];
  char initial[100];
  int n;
  
  fgets(input, sizeof(input), sursa);
  n = sscanf(input,"%99s %99[^'.']. %99[^','], %d, %f, %f, %f\n", lastName, initial, firstName, &amp;group, &amp;mark1, &amp;mark2, &amp;mark3);
  </code></pre>