Skip to content

I/O Format Specifiers for Read Operations

This topic discusses the format specifier fields that may appear in the read format control strings passed to the Printf-style I/O functions. The format specifiers described here apply to the following functions:

The read format specifier for all Printf-style functions has the following general form:

%[modifiers]type

The type code is the only required field and appears after the optional modifiers. The type code determines whether the associated argument is interpreted as a character, string, number, or array. The type code also determines which modifiers are valid and how they are interpreted. The specific format of the format specifier is given in the various topics in this section for each supported type code.

The table below lists the type codes available along with links to the topics that discuss the format specifier for each data type.

Type of DataFormat CodesHelp Topic
Single characters%cReading Characters
Strings%s, %t, %T, %[]Reading Strings
Integers%d, %i, %o, %u, %x, %XReading Integers
Floating-point numbers%f, %e, %E, %g, %GReading Floating-Point Numbers
IEEE 488.2 definite-length blocks%bReading IEEE 488.2 Binary Blocks
Raw binary data%yReading Raw Binary Data

Special formatting character sequences scan special characters. The following table lists the special characters and describes what they expect to receive from the device.

Formatting CharacterCharacter Expected from Device
\nReads the ASCII linefeed character (LF).
\rReads the ASCII carriage return (CR) character.
\tReads the ASCII TAB character.
\###Reads the ASCII character specified by the octal value.
\"Reads the ASCII double-quote (") character.
\\Reads the ASCII backslash (\) character.