FmtFile
- Updated2023-02-21
- 2 minute(s) read
FmtFile
int FmtFile (int fileHandle, char formatString[], ...);
Purpose
Formats the source1, . . ., sourcen arguments according to descriptions in the formatString argument. You can specify up to 29 source arguments. FmtFile writes the result of the formatting into the file that corresponds to the fileHandle argument. Call OpenFile to obtain the fileHandle.
The Using the Formatting and Scanning Functions section includes a complete discussion of FmtFile.
Parameters
Input | ||||||||||||
Name | Type | Description | ||||||||||
fileHandle | int | Specifies which file to write the data to. This is 1, 2, or the value that was originally returned by OpenFile. If the value is 1 or 2, data is written to the Standard I/O window. | ||||||||||
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:
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 file. 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. |
Return Value
Name | Type | Description |
ItemsFormatted | int | Number of source items successfully written to file. To get the number of bytes written to the file, call NumFmtdBytes. FmtFile returns –1 to indicate an error in the format string or –2 to indicate an I/O error. If FmtFile returns –2, you can use GetFmtIOError to get more information about the type of error that occurred. |
Additional Information
Library: Formatting and I/O Library
Include file: formatio.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later