Formatting and I/O Library Programming Examples

This 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.

Formatting Scanning
The Fmt/FmtFile/FmtOut examples are logically organized as shown: The Scan/ScanFile/ScanIn examples are logically organized as shown:
Integer to string String to integer
Short integer to string String to short integer
Real to string in floating-point notation String to real
Real to string in scientific notation String to integer and real
Integer and real to string with literals String to string
Two integers to ASCII file with error checking String to integer and string
Real array to ASCII file in columns and with comma separators String to real, skipping over non-numeric characters in the string
Integer array to binary file, assuming a fixed number of elements String to real, after finding a semicolon in the string
Real array to binary file, assuming a fixed number of elements String to real, after finding a substring in the string
Real array to binary file, assuming a variable number of elements String with comma-separated ASCII numbers to real array
Variable portion of a real array to a binary file Scanning strings that are not null-terminated
Concatenating two strings Integer array to real array
Appending to a string Integer array to real array with byte swapping
Creating an array of filenames Integer array that contains 1-byte integers to real array
Writing a line that contains an integer with literals to the standard output Strings that contain binary integers to integer array
Writing to the standard output without a linefeed or carriage return Strings that contain an IEEE-format real number to a real variable
ASCII file to two integers with error checking
ASCII file with comma-separated numbers to real array, with the number of elements at the beginning of file
Binary file to integer array, assuming a fixed number of elements
Binary file to real array, assuming a fixed number of elements
Binary file to real array, assuming a variable number of elements
Reading an integer from the standard input
Reading a string from the standard input
Reading a line from the standard input