vsprintf(3)

vsprintf3

String print formatted

Part of sprintf(3).

Usage

#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)):

snprintf(), vsnprintf():

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

Library

Standard C library (libc, -lc)

Overview

These functions are equivalent to snprintf(3) and vsnprintf(3), 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).

InterfaceAttributeValue
sprintf(), vsprintf()Thread safetyMT-Safe locale

Releases

19 releases since Debian 1.1 (Buzz); the text changed 18 times.

  1. 1.1
  2. 1.2
  3. 1.3
  4. 2.0
  5. 2.1
  6. 2.2
  7. 3.0
  8. 3.1
  9. 4.0
  10. 5.0
  11. 6.0
  12. 7
  13. 8
  14. 9
  15. 10
  16. 11
  17. 12
  18. 13
  19. Arch

Standards

C11, POSIX.1-2008.

History

C89, POSIX.1-2001.

Bugs

See printf(3).

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) and vasprintf(3)).

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.