Print formatted output to a length-bounded string
Synopsis:
#include <qdb/qdb.h>
char *qdb_snprintf( int n,
char *buf,
const char *format, ...);
Arguments:
- n
- The maximum number of characters to store in the buf string, including the null-terminator. The function will always write a null-terminator if n is positive.
- buf
- A pointer to the buffer for storing the formatted string.
- format
- A pointer to a formatting string to process. The formatting string determines what additional arguments you need to provide. For more information, see printf() in the
QNX Neutrino C Library Reference.
Description:
This function is a variant of snprintf() in the standard C library. However, it is different from snprintf() in these ways:
- qdb_snprintf() returns a pointer to the buffer rather than the number of characters written
- the order of the n and buf parameters is reversed
- qdb_snprintf() always writes a null-terminator if n is positive
For more information about additional formatting options, see qdb_mprintf().
CAUTION:
You shouldn't use the return value of this function. In future versions, it may be changed to return the number of characters written rather than a pointer to the buffer.
Returns:
- A pointer to the formatted output string (buf)
- Success.
- NULL
- An error occurred (errno is set).
Classification:
QNX Neutrino
Safety: |
|
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |