title: sscanf to float using c
body: <p>So I have a file that has multiple strings. I'm supposed to use <code>fgets</code> to read each line then use <code>sscanf</code> to break the string up and process them into my struct. Here's an example.</p>
  
  <pre><code>38L Lee, Victor; 2.8
  </code></pre>
  
  <p>The first is the id, second is name, and finally the gpa. When I try using sscanf to read the gpa, it's reading 0.0, rather than 2.8. Here's my code.</p>
  
  <pre><code>bool getstu (FILE* fpstu, STU* pstu)
  {
  
  //  Local Definitions
      int ioResult;
      char temp[100];
      char *ptr;
      char tempStr[50];
  
  //  Statements
      fgets(temp, sizeof(temp), fpstu);
      {
          ptr = temp;
          sscanf(ptr, "%3s", pstu-&gt;id);
          ptr += strlen(pstu-&gt;id) + 1;
          sscanf(ptr, "%[^;]", tempStr);
  
          pstu-&gt;name = aloName(tempStr);
  
          ptr += strlen(tempStr) + 2;
          sscanf(ptr, "%s", tempStr);
          sscanf(tempStr, "%3.1f", pstu-&gt;gpa);
      }
  
  return ioResult == 1;
  }// getstu
  </code></pre>
  
  <p>Can someone explain to me what I'm doing wrong and how I can fix this problem?</p>