title: C fscanf discarding extra characters if there is any
body: <p>I'm working on this project for one of my classes and it states, "Discard everything after the three digit characters up to and including the next newline or EOF".</p>
  
  <p>For example, the following would be a example test configuration file:</p>
  
  <pre><code>119
  3561234
  263abc
  </code></pre>
  
  <p>I need to save the first three digit characters to individual variables defined as row, column, value (respectively).</p>
  
  <p>The code I have so far is the following:</p>
  
  <pre><code>/*
   * Read in the initial puzzle configuration.
   * Each line is 4 characters long:
   *   Row    as a character '0' .. '9'
   *   Column as character '0' .. '9'
   *   Digit  as character '0' .. '9'
   *   Terminating newline.
   * Exits with an error message if there are syntactic
   * or semantic errors with any configuration line.
   */
  
  void configure(FILE *puzzle_file) {
  
      int row, column, value; // Variables
      int count = 1; //the counter for what line we are on 
  
      /*
       * Loops through every line transforming the chars to character int values
       * for each int needed and addes it to puzzle and changes fixed values
       * at same location.
       */
      while((fscanf(puzzle_file, "%1i%1i%1i%*[^\n]", &amp;row, &amp;column, &amp;value)) != EOF){
              if(!in_range(row) || !in_range(column) || !in_range(value)){
                      printf("Illegal format in configuration file at line %i\n", count);
                      exit(1);
              }
              if(puzzle[row][column] != 0){
                      printf("Illegal placement in configuration file at line %i\n",count);
                      exit(1);
              }
  
              puzzle[row][column] = value;
              fixed[row][column] = 1;
  
              count++;
      }
  
  }
  </code></pre>
  
  <p>I would expect that 9 would go in row 1 and column 1, 6 go in row 3 and column 5, and 3 would go in row 2 and column 6.</p>
  
  <p>With a proper formated config file it will go into the first if statement and end there.</p>
  
  <p>Proper config file example:</p>
  
  <pre><code>123
  356
  235
  etc..
  </code></pre>
  
  <p>I'm assuming its my fscanf thats making it not work correctly. How would you change that so it would do that?</p>
  
  <p>EDIT 1:</p>
  
  <p>in_range function:</p>
  
  <pre><code>/*
   * Return TRUE iff the value is in the Sudoku range (1 .. 9)
   */
  static bool in_range(int value) {
  
      if(isdigit(value) &amp;&amp; value != 0){
              return TRUE;
      }
      return FALSE;
  }
  </code></pre>