title: Read/Parse File
body: <p>Recently I saw a piece of code here and I just wanted to change it up so see how I would read multiple lines through a file. Lets say the file has the following:</p>
  
  <pre><code>3 5 2 2 0 4 6 4 4 1 3 4 5 0 4 5 6 2 0 0 1 
  4 0 1 2 0 3 1 4 1 0 0 1 2 3 
  </code></pre>
  
  <p>So it parses just singular line, but I would like to do another line.</p>
  
  <pre><code>while (fgets(buffer, sizeof(buffer)-1, fp))
  {
      if(buffer[strlen(buffer) - 1] == '\n')
          buffer[strlen(buffer) - 1] = '\0';
  
      while((result = fgetc(fp)) != EOF )
      {
          //removes the end newline and replaces with a null
          if(fileContents[strlen(fileContents) - 1] == '\n')
              fileContents[strlen(fileContents) - 1] = '\0';
  
          //if a digit is in place and has been updated
          //then count++ and go ahead and store the result in an
          //Array, which will minus ASCII value 48 to get our #
          if( isdigit( result )  )
          {
              if( currentState == NOT_IN_NUMBER )
              { 
                  //debug statement
                  //printf("ASCII = %d\n",result);
                  //minus 48 to get to our base 10 ints
                  numberArray[count++] = result - 48;
                  if(count == 1)
                  {
                      how_many_page = result - 48;
                  }
                  //count++;
                  currentState = IN_NUMBER; //Jp
              }
          }
          else
          {
              //a space is found
              currentState = NOT_IN_NUMBER;
          }
      }
  }
  </code></pre>
  
  <p>The only thing that I added was the:</p>
  
  <pre><code>while (fgets(buffer, sizeof(buffer)-1, fp))
  {
      if(buffer[strlen(buffer) - 1] == '\n')
          buffer[strlen(buffer) - 1] = '\0';
  ....
  </code></pre>
  
  <p>Thank you for your help.</p>