Quantcast
Channel: check – PenTesting | Hacking | Coding
Viewing all articles
Browse latest Browse all 11

Check if file exists in C

$
0
0

Don’t forget to define true and false constants.

#define TRUE 1
#define FALSE 0
int file_exists(const char *filename)
{
    FILE *file = fopen(filename, "r");
    if (file)
    {
        fclose(file);
        return TRUE;
    }
    return FALSE;
}

Viewing all articles
Browse latest Browse all 11

Trending Articles