title: unable to read text from file in C
body: <p>I have this code that's supposed to read from a text file and print its content but I keep getting &quot;Unable to open file.&quot;</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  #define MAX 4000
  int main(void)
  {
      FILE *bkptr;
      char buffer[MAX];
  
      bkptr = fopen(&quot;defoe-robinson-103.txt&quot;, &quot;r&quot;);
  // If file dow not open
      if (bkptr == NULL) {
          puts(&quot;Unable to open file.&quot;);
      }
  // If file open
      else {
  // Read each line form file until EOF
          while (fgets(buffer, MAX, bkptr)) {
  // Print the line
              puts(buffer);
          }
  
  // Close the file
          fclose(bkptr);
      }
  }
  </code></pre>