warning: passing argument 2 of ‘fopen’ makes pointer from integer without a cast
<p>I have this function to check if a file exists:</p>

<pre><code>#include &lt;stdio.h&gt;

int main(int argc, char **argv) {
    int textFileExists(const char *filename){
        FILE *fp=   fopen(filename,'r');
        if(fp==NULL){
            printf("%s %s.\n","There was an error opening ", filename);
            return -1;
        }
        return 1;
    }

    textFileExists("text.txt");
    return 0;
}
</code></pre>

<p>But when I compile this code, I get this warning.</p>

<pre><code>warning: passing argument 2 of ‘fopen’ makes pointer from integer without a cast
  FILE *fp= fopen(filename,'r');
</code></pre>

<p>Running this code gives me a segmentation fault.</p>

<p>What is going on here?</p>