---
name: "replace_extension"
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/replace_extension"
---

# replace\_extension(3alleg)

Replaces filename+extension with a new extension tail. Allegro game programming library.

## NAME

replace\_extension - Replaces filename+extension with a new extension tail. Allegro game programming library.

## SYNOPSIS

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

**char \*replace\_extension(char \*dest, const char \*filename,** **const char \*ext, int size);**

## DESCRIPTION

Replaces the specified filename+extension with a new extension tail, storing at most \`size' bytes into the \`dest' buffer. If the filename doesn't have any extension at all, \`ext' will be appended to it, adding a dot character if needed. You can use the same buffer both as input and output because Allegro internally works on a copy of the input before touching \`dest'. Example:

```
   replace_extension(buf, "C:\\game\\prog.exe",
                     "dat", sizeof(buf));
```

## RETURN VALUE

Returns a copy of the \`dest' parameter.

## SEE ALSO

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