Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Return a string pointer to a filename's extension */
- char* GetFileExt(char* fileName)
- {
- /* Initialize return pointer
- (will contain address of the filename string's extension,
- at the location of the '.' character) */
- char* extPtr = NULL;
- do
- {
- /* If current position of the filename string is the '.' character,
- update return pointer */
- if (*fileName == '.')
- {
- extPtr = fileName;
- }
- /* Continue until we reach the end of the filename string
- (accounts for '.'s appearing in filenames before the extension) */
- } while (*fileName++ != '\0');
- /* Return */
- return extPtr;
- }
Add Comment
Please, Sign In to add comment