#include <stdio.h>
#include <string.h>

static const char*
get_file_ext(const char *filename) {
   const char *ext = strrchr(filename, '.');
   return (ext && ext != filename) ? ext : (filename + strlen(filename));
}

int main() {
  char *files[] = {"a.c", ".a", "a", NULL };

  for (char** f = files; *f != NULL; ++f)
    printf("ext: '%s'\n", get_file_ext(*f));
}
