get_extension(3alleg4)

✨ get_extension ✨

okay bestie, welcome to the get_extension page of the Allegro manual (yes that's the manual name, get_extension(3alleg4), we're in the Allegro game programming library era and it's giving retro royalty πŸ‘‘).

NAME β€” get_extension β€” returns a pointer to the extension of a filename. Part of the Allegro game programming library, obviously πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

char *get_extension(const char *filename);

πŸŽ€ DESCRIPTION πŸŽ€

So what it does is it sniffs out the extension of the filename you hand it β€” and it does NOT care whether you gave it path info or not, it handles both, no cap 🫢. Here's the example straight from the source:

get_executable_name(name, sizeof(name));
allegro_message("The binary has the extension `%s'\n",
                get_extension(name));

πŸ’– RETURN VALUE πŸ’–

It hands you back a pointer to the exact spot inside filename where the extension kicks in ✨.

BUT β€” and listen, this is the plot twist 😭 β€” if there's no filename at all, or the thing just doesn't have an extension, you get a pointer to the trailing null character instead. Like, an empty vibe. Nothing to see here. 🌈


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie, you ate it πŸ’…βœ¨ this was get_extension from Allegro version 4.4.3 β€” iconic behavior, fr fr πŸŽ€πŸ«Ά