LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

vsnprintf

vsnprintf

int vsnprintf (char targetString[], size_t bufferSize, const char formatString[], ...);

Purpose

Writes output to the specified string according to format specifiers in formatString. This function is similar to snprintf except that vsnprintf takes as a parameter an argument list initialized by the va_start macro.

Note Note  You cannot execute this function panel because of the nature of how variable argument lists are created.

Parameters

Input
Name Type Description
bufferSize size_t Pass the maximum number of bytes that may be written to the targetString buffer, including the null byte. This is typically just the size of the buffer.
formatString const char [] Contains the format string that specifies how subsequent arguments are converted for output. Use standard ANSI C format specifiers. If insufficient arguments exist for the format, the behavior is undefined. If the format is exhausted while arguments remain, the excess arguments are evaluated but are otherwise ignored.
Note Note  For more information about the standard ANSI C format specifiers, refer to an external ANSI C reference.
argumentList ... Contains a variable argument list initialized by the va_start macro and possibly subsequent va_arg calls.
Output
Name Type Description
targetString char [] Contains the string to which the formatted data is written. A null character is written at the end of the characters written to this parameter.

If you want only to query the buffer size required for the formatted string without actually doing the formatting, you may pass NULL for this parameter and 0 for the bufferSize.

Return Value

Name Type Description
formattedStringSize int The number of bytes that would have been written had bufferSize been sufficiently large, or a negative value if an output error occurred. This value can be compared with bufferSize to determine if truncation occurred.
Note Note  The terminating null character is not included in the count.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 9.0 and later

Was this information helpful?