chsvlib
chsv helper source code

◆ snPrintfA()

int Chusov::String::snPrintfA ( char *restrict  pDest,
std::size_t  cchDest,
const char *restrict  pszFormat,
  ... 
)
noexcept

Loads the data from the given locations, converts it to multibyte string equivalents and writes the results to a string buffer.

Parameters
[out]pDestis a pointer to the output buffer where the converted string is to be written to. A size, in bytes, of the buffer is specified by cchDest.
[in]cchDestis a size, in bytes, of the output buffer. If cchDest is zero, pDest may be a null pointer. At most \((cchDest - 1)\) bytes of the formatted string are written to the output buffer. A zero terminator is always appended to the end of the output string.
[in]pszFormatis a pointer to a zero terminated string defining how to interpret data, passed as additional parameters, during construction of the output. See PrintfA for the definition of the format lexemes.
...constitute an optional set of additional parameters to build the formatted output according to pszFormat.
Returns
On success the function returns a number of bytes that would have been written had cchDest been sufficiently large, not counting the terminating zero. If an error occurs the function returns a negative number setting the corresponding errno code. Thus an output string has been completely written to the output buffer if and only if the function returns a nonnegative number strictly less than cchDest.

The function implements the behaviour of the standard C vsnprintf function with full accordance to ISO/IEC 9899:1999 (aka C99) and ISO/IEC 9899:2011 (aka C11) with some standard-compatible extensions specific to the chsvlib library. See PrintfA for the details.

See also
PrintfA;
snPrintfW;
snPrintfA_s.