---
name: "sprintf"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/sprintf"
---

# sprintf(3)

string print formatted

## NAME

sprintf, vsprintf - string print formatted

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <stdio.h>
```

**int sprintf(char \*restrict** *str***,**             **const char \*restrict** *format***, ...);** **int vsprintf(char \*restrict** *str***,**             **const char \*restrict** *format***, va\_list** *ap***);**

Feature Test Macro Requirements for glibc (see [**feature\_test\_macros**(7)](/feature_test_macros/7.md)):

**snprintf**(), **vsnprintf**():

```
    _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE
```

## DESCRIPTION

These functions are equivalent to [**snprintf**(3)](/snprintf/3.md) and [**vsnprintf**(3)](/vsnprintf/3.md), except that no check for buffer overrun is performed (see BUGS below).

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **sprintf**(), **vsprintf**() | Thread safety | MT-Safe locale |

## STANDARDS

C11, POSIX.1-2008.

## HISTORY

C89, POSIX.1-2001.

## BUGS

See [**printf**(3)](/printf/3.md).

### sprintf(), vsprintf()

Because **sprintf**() and **vsprintf**() assume an arbitrarily long string, callers must be careful not to overflow the actual space; this is often impossible to assure. Note that the length of the strings produced is locale-dependent and difficult to predict. Use **snprintf**() and **vsnprintf**() instead (or [**asprintf**(3)](/asprintf/3.md) and [**vasprintf**(3)](/vasprintf/3.md)).

## SEE ALSO

[**asprintf**(3)](/asprintf/3.md), [**snprintf**(3)](/snprintf/3.md)
