qdb_snprintf()

Updated: April 19, 2023

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. This string determines what additional arguments you need to provide. For more information, see printf() in the QNX Neutrino C Library Reference.

Library:

qdb

Description:

This function is a variant of snprintf() in the standard C library. It differs 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 information about additional formatting options supported by QDB (but not printf()), see qdb_mprintf().

CAUTION:
Don'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
Success.
NULL
An error occurred (errno is set).

Classification:

QNX Neutrino

Safety:  
Interrupt handler No
Signal handler No
Thread Yes