Programming Tips - How can I get the extension of a filename?

Date: 2013dec19 Language: C/C++ Keywords: suffix Q. How can I get the extension of a filename? A.
char *GetExtensionSimple(const char *filename) { char *p; if (filename == NULL) return NULL; if ((p = strrchr(filename, '.')) == NULL) return &filename[lstrlen(filename)]; return p; }
This handles a NULL filename, or a filename with no extension. There are also library routines for this - but this works everywhere.