title: Getting string where a float should be?
body: <p>I couldn't find any other examples, so I'm hoping someone could point me in the right direction.  My program has to be able to handle a text file that has a list of cars,</p>
  
  <p>modelname year rentalrate   &lt;-- is how the text file is formatted.  My professor throws in a SPECIAL for the rentalrate sometimes and I need to be able to replace that with the daily special price, which is in the function call.  I use sscanf to parse the file, but my code is generating an error when I get to the SPECIAL.  Any ideas how this can be handled better?  I would really appreciate it.</p>
  
  <pre><code>int readCar(Car *s, float special)// function b
  {
          int success;
          char *str = malloc(MAXCARS * sizeof(char));
          char *output = malloc(MAXCARS * sizeof(char));
          fgets(str, MAX_LINES, stdin);
          success = (sscanf(str, "%s %d %f",s-&gt;modelName, &amp;s-&gt;year, &amp;s-&gt;rentalRate));
          sprintf(output,"%f",s-&gt;rentalRate);
  
          if(strcmp(output, "SPECIAL")== 0)
          {
                  s-&gt;rentalRate = special;
          }
          else if(success == 3)
          {
                  return 0;
          }
          else
                  return 1;
  }
  </code></pre>
  
  <p>The below function is the function calling the above function.  Not sure if this is needed but I figured I could throw it in.</p>
  
  <pre><code>int readArray(Car *cars, int elemNums, float special)// function c
  {
      int carCount;
      int error;
      scanf("%d", &amp;carCount);
      if((carCount)&gt;elemNums)
      {
           printf("\nError: Number of cars exceeds database limit.\n\n");
           exit(1);
      }
      //int i = 0;
      Car* c;
      for(c = cars; c &lt; (cars + elemNums); c++)
      {
           error=readCar(c, special);
           if(error==1)
           {
                printf("\nError on line: %s %d $%.2f\n\n", c-&gt;modelName, c-&gt;year, c-&gt;rentalRate);
                exit(1);
           }
      }
          fflush(stdout);
          return carCount;
  }
  </code></pre>