title: C program to read a text file line by line then print out those lines to the terminal
body: <p>I want to have a c program read a text file line by line then print out those lines to the terminal.</p>
  
  <p>My code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)
  {
      char* line; 
  
      FILE *ifp;
      ifp = fopen("BBE.txt", "r");
      if (ifp == NULL)
      {
          printf("Error opening file!\n");
          exit(1);
      }
  
      while (fscanf(ifp, "%s", line) == 1)
      {
          printf("%s\n", line);
      }
  
      fclose(ifp);
  
      return 0;
  }
  </code></pre>
  
  <p>The program when i try to run it does not print out anything to the terminal. This tells me that the while loop is not working but i am not to sure as to why. </p>