JP van Oosten

Stripping file extensions in C

Sep 14, 2009

A very simple C-function to strip all extensions from a filename. The function removes everything from the first dot.

void strip_extension(char *name)
{
    while (*++name != '.' && *name != 0)
        ;
    *name = 0;
}