sprintf (3) Linux Manual Page
printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf, vdprintf, vsprintf, vsnprintf – formatted output conversion
Synopsis
#include <stdio.h>int printf(const char *format, ...);int fprintf(FILE *stream, const char *format, ...);int dprintf(intfd, const char *format, ...);int sprintf(char *str, const char *format, ...);int snprintf(char *str, size_tsize, const char *format, ...);#include <stdarg.h>int vprintf(const char *format, va_listap);int vfprintf(FILE *stream, const char *format, va_listap);int vdprintf(intfd, const char *format, va_listap);int vsprintf(char *str, const char *format, va_listap);int vsnprintf(char *str, size_tsize, const char *format, va_listap);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
snprintf(), vsnprintf():
- _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE ||
|| /* Glibc versions <= 2.19: */ _BSD_SOURCE
dprintf(), vdprintf():
-
- Since glibc 2.10:
- _POSIX_C_SOURCE >= 200809L
- Before glibc 2.10:
- _GNU_SOURCE
Description
The functions in the printf() family produce output according to a format as described below. The functions printf() and vprintf() write output to stdout, the standard output stream; fprintf() and vfprintf() write output to the given output stream; sprintf(), snprintf(), vsprintf(), and vsnprintf() write to the character string str.
The function dprintf() is the same as fprintf() except that it outputs to a file descriptor, fd, instead of to a stdio stream.
The functions snprintf() and vsnprintf() write at most size bytes (including the terminating null byte (‘
