title: Error: ‘fp’ is used uninitialized in this function [-Werror=uninitialized]
body: <p>I am relatively new to using files in C. Today, when I was working on my program, when I declared a FILE pointer and tried to utilize it,
  I keep getting this error:</p>
  <pre><code>answer3.c:44:5: error: ‘fp’ is used uninitialized in this function [-Werror=uninitialized]
     if(fp == NULL)
       ^
  cc1: all warnings being treated as errors
  </code></pre>
  <p>Here is my code</p>
  <pre><code>bool  runIntegrate(char * infilename, char * outfilename)
      // return true if it can successfully open and read the input 
      // and open and write the output
      // return false when encountering any problem
      {
        Integration intrg;
        FILE * fp;
        fopen(infilename,&quot;r&quot;);
        // open the input file name for reading
        // if fopen fails, return false
        if(fp == NULL)
         {
          fclose(fp);
          return false;            
         }
        
        if (fscanf(fp,&quot;%lf\n&quot;, &amp;intrg.lowerlimit) != 1){
          fclose(fp);
          return false;
        }
  </code></pre>
  <p>I am pretty sure I have the formatting correct, so I am not too sure what the issue seems to be. Any help would be greatly appreciated. Thank you!</p>