snprintf(3scl)snprintf(3scl)NAMEsnprintf - print formatted output to a buffer
LIBRARY
SCL Miscellaneous Library (libsolmisc.so, libsolmisc.a)
SYNOPSIS
#include <stdio.h>
int snprintf(char *string,
size_t n,
const char *format, ...);
PARAMETERS
Pointer to buffer to contain formatted output string. Size of the buf‐
fer referred to by string. Pointer to buffer containing a string spec‐
ifying the characters and format of optional parameters (...) to be
written to string.
DESCRIPTION
The snprintf() function behaves as function sprintf(3) except that
parameter n restricts the number of characters written to the output
buffer.
SCL IMPLEMENTATION NOTES
The output buffer is assumed to be large enough to contain the format‐
ted output, otherwise an error is returned. This is different behaviour
to Solaris which returns the number of characters that should have been
output if the buffer was sufficiently large.
Tru64 UNIX version 5 implements the snprintf() function in the standard
library, but Tru64 UNIX version 4 does not, hence the function is
implemented by the SCL.
The SCL-supplied stdio.h header maps snprintf() to an SCL-specific
implementation function. This mapping is not required if building
applications on Tru64 UNIX version 5. Consequently, the header uses
preprocessor statements to only map the definition when building on a
version 4 system.
To ensure that the correct preprocessor symbol is defined for the con‐
ditional test within the header, use the tru64_version utility (in the
bin directory beneath the SCL root directory) with the application
build command (for example: cc -o myprog -D`tru64_version -m` myprog.c
-lsolmisc). Alternatively, remove the definitions from the SCL-sup‐
plied stdio.h on a version 5 system.
RETURN VALUES
The number of characters written to the buffer, excluding the terminat‐
ing null, if successful, otherwise a negative value is returned.
RELATED INFORMATION
Functions: sprintf(3), vfprintf(3)
Manual: Solaris Compatibility Library User's Guide
snprintf(3scl)