---
name: "al_cstr"
section: "3"
platform: "linux"
package: "allegro"
version: "5.2.11.3-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/al_cstr"
---

# al\_cstr(3)

Allegro 5 API

## NAME

al\_cstr - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro.h>
  const char *al_cstr(const ALLEGRO_USTR *us)
  ```

## DESCRIPTION

Get a `char *` pointer to the data in a string. This pointer will only be valid while the [ALLEGRO\_USTR(3)](/ALLEGRO_USTR/3.md) object is not modified and not destroyed. The pointer may be passed to functions expecting C-style strings, with the following caveats:

- •

  ALLEGRO\_USTRs are allowed to contain embedded NUL (`'\0'`) bytes. That means `al_ustr_size(u)` and `strlen(al_cstr(u))` may not agree.

- •

  An ALLEGRO\_USTR may be created in such a way that it is not NUL terminated. A string which is dynamically allocated will always be NUL terminated, but a string which references the middle of another string or region of memory will *not* be NUL terminated.

- •

  If the ALLEGRO\_USTR references another string, the returned C string will point into the referenced string. Again, no NUL terminator will be added to the referenced string.

## SEE ALSO

[al\_ustr\_to\_buffer(3)](/al_ustr_to_buffer/3.md), [al\_cstr\_dup(3)](/al_cstr_dup/3.md)
