---
name: "get_filename"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/get_filename"
---

# get\_filename(3alleg)

Returns a pointer to the filename portion of a path. Allegro game programming library.

## NAME

get\_filename - Returns a pointer to the filename portion of a path. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**char \*get\_filename(const char \*path);**

## DESCRIPTION

Finds out the filename portion of a completely specified file path. Both \`\\' and \`/' are recognized as directory separators under DOS and Windows. However, only \`/' is recognized as directory separator under other platforms. Example:

```
   get_executable_name(name, sizeof(name));
   allegro_message("Running `%s'\n", get_filename(name));
```

Note that Allegro won't perform any IO operations during the verification. This means that if you have \`/a/path/like/this/', which doesn't have a filename, the function will return a pointer to the trailing null character. However, if you have \`/a/path/like/this', Allegro will return a pointer to \`this', even if it is a valid directory.

## RETURN VALUE

Returns a pointer to the portion of \`path' where the filename starts, or the beginning of \`path' if no valid filename is found (eg. you are processing a path with backslashes under Unix).

## SEE ALSO

[**get\_extension**(3alleg)](/get_extension/3alleg.md), [**put\_backslash**(3alleg)](/put_backslash/3alleg.md), [**replace\_filename**(3alleg)](/replace_filename/3alleg.md), [**exmidi**(3alleg)](/exmidi/3alleg.md)
