title: Simple C program to read a file line by line
body: <p>What I would like to do is read the whole first line of the file but then after the first line only read the following lines until whitespace is hit. My end goal is to ask the user what line they want to edit by adding/subtracting time to said line.</p>
  
  <p>Sample File</p>
  
  <pre><code>My test file
  00:19.1 123456
  00:35.4 testing whitespace end
  </code></pre>
  
  <p>Desired Output</p>
  
  <pre><code>1: My test file
  2: 00:19.1
  3: 00:35.4
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      FILE *fptr1, *fptr2;
  
      char filechar[40];
      char c[50];
      int line_number = 1;
      int replace_line, temp = 1;
  
      printf("Please enter a file name: ");
      scanf("%s", &amp;filechar);
  
      if ((fptr1 = fopen(filechar, "r")) == NULL)
      {
          printf("Error locating desired file");
          exit(1);
      }
  
      c = getc(fptr1);
      while (c != EOF)
      {
          //printf("%d: %c",line_number, c);
          printf("%s",c);
          c = getc(fptr1);
          //line_number++;
      }
      return 0;
  }
  </code></pre>