www.delorie.com/djgpp/doc/libc/libc_732.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

snprintf

Syntax

 
#include <stdio.h>

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

Description

This function works similarly to sprintf() (see section sprintf), but the size n of the buffer is also taken into account. This function will write n - 1 characters. The nth character is used for the terminating nul. If n is zero, buffer is not touched.

Return Value

The number of characters that would have been written (excluding the trailing nul) is returned; otherwise -1 is returned to flag encoding or buffer space errors.

The maximum accepted value of n is INT_MAX. INT_MAX is defined in <limits.h>. -1 is returned and errno is set to EFBIG, if n is greater than this limit.

Portability

ANSI/ISO C C89; C99 (see note 1)

Notes:

  1. The buffer size limit is imposed by DJGPP. Other systems may not have this limitation.


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004