title: passing argument 1 of 'fopen' from incompatible pointer type?
body: <p>I'm stuck for sometime in this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  const char *fn; int a;
  
  int exists(const char *fname)
  {
      FILE *file;
      if (file = fopen(fname, "r"))
      {
          fclose(file);
          return 1;
      }
      return 0;
  }
  
  main(){
  
      printf("Name:\n");
      scanf("%s",&amp;fn);
  
      a=exists(&amp;fn)
  
      if(a==0){
          fopen(&amp;fn,"w");
          fprintf(fn,"banhdhsjha");
      }
  }
  </code></pre>
  
  <p>When I try to run the program, it works until <code>fprintf(fn,"banhdhsjha");</code>, but it crashes here <a href="http://i.imgur.com/EIaErFs.png" rel="nofollow">(Windows gives me an error)</a> and the compiler (CodeBlocks) gives me the following notice:</p>
  
  <blockquote>
    <p>passing argument 1 of 'fopen' from incompatible pointer type.</p>
  </blockquote>
  
  <p>I am trying to make <code>fprintf</code> write data in the file, but I don't know how to do it. Can you help me?</p>