Admin Production ni-theme
Current Publication

Fmt

LabWindows/CVI

Fmt

int Fmt (void *target, char formatString[], ...);

Purpose

Formats the source1, . . ., sourcen arguments according to descriptions in the formatString argument. You can specify up to 29 source arguments.

Fmt places the result of the formatting into the target argument, which you must pass by reference. The return value indicates how many source format specifiers were satisfied. If the format string is invalid, the return value is –1. The Using the Formatting and Scanning Functions section includes a complete discussion of Fmt.

Parameters

Input
Name Type Description
formatString char [] Contains format specifiers that appropriately describe the source and target data to be formatted.

For the three format functions, the source specifiers must be provided in the format string.

You may omit the target specifier, in which case the target is assumed to be %s (string). If a target data type other than string is desired, the format string must begin with the specifier of the desired target type, followed by the "‹" symbol, followed by the source specifiers.

For example, the following calls are equivalent:

x = Fmt (s, "%d", k)

x = Fmt (s, "%s‹%d", k)

The following list includes common specifiers:

%d Indicates that the source or target is an integer.
%i Same as %d.
%f Indicates that the source or target is a double–precision real number.
%s Indicates that the source or target is a string. Numeric values may be converted into ASCII form using the %s target specifier.
%10f Indicates that the source or target is an array of ten double–precision real numbers.

Because the data formatting functions can describe many complex formatting operations, refer to the Using the Formatting and Scanning Functions section to make sure you are using the proper format specifier for your application.
source_s ... Specifies one or more arguments to convert and write to the target. Each argument must match its corresponding type specifier in the format string. You can specify up to 29 arguments, and you must separate the arguments with commas.
Output
Name Type Description
target void * Specifies the variable in which the formatted items are stored.

Refer to the Using the Formatting and Scanning Functions section for more information.

Return Value

Name Type Description
ItemsFormatted int Number of source format specifiers satisfied. To get the number of bytes placed into the target item, call NumFmtdBytes.

Fmt returns –1 to indicate an error in the format string.

Additional Information

Library: Formatting and I/O Library

Include file: formatio.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Examples

Refer to the following examples that use the Fmt function:

  • apps\daqmthread\daqMT.cws

    Open example
  • dll\simple\cvi\simple.cws

    Open example
  • rs232\commcallback.cws

    Open example
  • rs232\serial.cws

    Open example
  • userint\treeevent.cws

    Open example