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

Check file extension in C

$
0
0

Don’t forget to define true and false constants.

#define TRUE 1
#define FALSE 0
int is_exe_extension(const char *filename)
{
    char *ext = strrchr(filename, '.');
    if (!ext)
        return FALSE;
    else
    {
        if(strcmp("exe", ext + 1) == 0)
            return TRUE;
        return FALSE;
    }
}

Viewing all articles
Browse latest Browse all 11

Trending Articles