Chapter 2 Formatting and I/O Library
© National Instruments Corporation 2-49 LabWindows/CVI Standard Libraries
Some formats may have been correctly detected in the input, and the corresponding target
parameters will have been filled in. Formats situated after the literal which did not appear,
however, will not have been executed.
The function return value can be used to determine exactly how many target parameters were
actually fulfilled by the input. You can use the function NumFmtdBytes to determine the
number of bytes consumed from the source parameter.
Because the left side of the > symbol must be a single format specifier, literal characters, if
present, must be on the right side of the symbol. Literals on the left side, or more than one
format specifier on the left side, result in a -1 error, indicating a faulty format string. The
function GetFmtErrNdx can then be used to determine exactly where in the format string the
error lies.
The characters %, [, ], <, and > have special meaning in the format strings. To specify that these
characters be taken literally, they should be preceded by %.
Formatting and I/O Library Programming ExamplesThis section contains examples of program code that use the Formatting and I/O Library
functions. The formatting and scanning functions are the basis of most of the examples.
The Fmt/FmtFile/FmtOut examples are logically organized as shown:
Integer to String
Long Integer to String
Real to String in Floating-Point Notation
Real to String in Scientific Notation
Integer and Real to String with Literals
Two Integers to ASCII File with Error Checking
Real Array to ASCII File in Columns and with Comma Separators
Integer Array to Binary File, Assuming a Fixed Number of Elements
Real Array to Binary File, Assuming a Fixed Number of Elements
Real Array to Binary File, Assuming a Variable Number of Elements
A Variable Portion of a Real Array to a Binary File
Concatenating Two Strings
Appending to a String
Creating an Array of File Names
Writing a Line Containing an Integer with Literals to the Standard Output
Writing to the Standard Output without a Linefeed/Carriage Return
The Scan/ScanFile/ScanIn examples are logically organized as shown:
String to Integer
String to Long Integer
String to Real