| Using VISA.NET > Formatted I/O > Using Scanf > Scanf Format Specifier Syntax > Scanf Flags |
Flags are optional characters or strings that control justification of output and printing of signs, blanks, decimal points, and octal and hexadecimal prefixes. Flags immediately follow the '%' character that begins the format specifier. More than one flag can appear in a format specification.
![]() |
Do not use format specifiers that include an invalid flag, an invalid combination of flags, or flags that are out of order. The results of such format specifiers are undefined, and they may cause Scanf to throw an exception or return arbitrary results. Note that since Scanf does not always throw an exception in these cases, it is important to read and follow these rules, including the ones in the table, carefully. |
VISA.NET recognizes one ANSI-defined flag ('*') and several VISA-specific flags that support IEEE 488.2 formatting ('@1', '@2', '@3', '@H', '@Q', and '@B'. The following general rules are observed when determining what combinations of flags are valid in a format specifier:
Additional, more specific rules are also noted in the table below.
|
Flag |
Applicable Types |
Description |
|---|---|---|
|
'*' |
c, s, t, T [<m>], [^<m>] d, i, o, u, x, X e, E, f, g, G b, y |
The field in the input that corresponds to this format specifier is read but not stored in an output argument. |
|
'Q', 'q' |
s |
Strings are enclosed in double ('Q') or single ('q') quotes. Since whitespace affects the way that string arrays are parsed, the use of quotes is required to remove ambiguity about the meaning of a comma separated string array where the elements of the array may contain whitespace. For string arrays, individual elements are enclosed in double or single quotes. |
|
'@1' |
d, i, u |
The input value(s) are formatted as a number. The number does not need to be formatted in IEEE 488.2 NR1 format. |
|
'@2' |
e, E, f, g, G |
The input value(s) are formatted as a number. The number does not need to be formatted in IEEE 488.2 NR2 format. |
|
'@3' |
e, E, f, g, G |
The input value(s) are formatted as a number. The number does not need to be formatted in IEEE 488.2 NR3 format. |
|
'@H' |
d, i, u, x, X |
Optional. The input value(s) are formatted in IEEE 488.2 <HEXADECIMAL_NUMERIC_RESPONSE_DATA> format. |
|
'@Q' |
d, i, o, u |
Optional. The input value(s) are formatted in IEEE 488.2 <OCTAL_NUMERIC_RESPONSE_DATA> format. |
|
'@B' |
d, i, o, u, x, X
|
Optional. The input value(s) are formatted in IEEE 488.2 <BINARY_NUMERIC_RESPONSE_DATA> format. |