## snprintf

#### OS/161 Reference Manual

### Name

snprintf - print formatted text to string

### Library

Standard C Library (libc, -lc)

### Synopsis

#include <unistd.h>
int
snprintf(char *buf, size_t buflen, const char *format, ...);
int
vsnprintf(char *buf, size_t buflen, const char *format, va_list);

### Description

snprintf performs printf-style formatting on the string format and subsequent arguments. The resulting string is placed in buf, which is a memory area at least buflen bytes long. A null terminator is always added to buf; the space for this is presumed to be counted in buflen.

vsnprintf is the same as snprintf, except that the subsequent arguments are presumed to have already been collected using the stdarg facility.

### Return Values

snprintf and vsnprintf return the number of characters printed.