Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

snprintf - formatted output to a string

&pagelevel(4)&pagelevel

Syntax

#include <stdio.h>

int snprintf(char *s, size_t n, const char *format, ...); 

Description

snprintf() edits data (characters, strings, numerical values) according to specifications in the string format and writes this data to the area pointed to by s.

snprintf() only outputs up to the buffer limit specified by the n parameter. This prevents buffer overrun. Apart from that the functionality of snprintf() is the same as that of sprintf().

snprintf() exists, analogous to sprintf() , as an ASCII, IEEE and ASCII/IEEE function (cf. sections “IEEE floating-point arithmetic” and “ASCII encoding”).

Parameters:
See fprintf().

Return val.

< 0

n > INT_MAX or output error.


= 0 .. n-1

It was possible to edit the output completely. The return value specifies the length of the output without the terminating NULL character.

 

> n

It was not possible to edit the output completely. The return value specifies the length of the output without the terminating NULL character which a complete output would require.