| Using VISA.NET > Formatted I/O > Using Scanf > Scanf Code Snippets > Reading Characters |
A character argument has a format specifier of the following form:
%[flags]c
|
Modifier |
Interpretation |
|---|---|
|
Default Functionality |
The data in the read buffer is parsed as a character. |
|
flags * |
Controls parsing, as follows: '*' indicates that the data is to be parsed and skipped; there is no corresponding output argument in the Scanf call. |
Remember that Scanf is reading bytes from the formatted read buffer, parsing them according to the format specifiers, and placing the results in an output variable. The preceding comment for each line shows the data being parsed by the snippet, and the resulting value that is returned in the corresponding output argument, like this: // "<data to parse>", "<value>". The <value> may optionally be followed by a comment in parentheses.
Assume that the io variable is a valid reference to IMessageBasedFormattedIO. Assume that result1 is an out argument declared as a .NET character.
| Character Parsing Snippets |
Copy Code |
|---|---|
|
// "C\n", "" io.Scanf("C", out result1); // "C\n", "C" io.Scanf("%c", out result1); // "C\n", "C" ( buffer is cleared ) io.Scanf("%c\n", out result1); // "ABC\n", "C" io.Scanf("AB%c", out result1); // "ABC\n", "A" io.Scanf("%cBC", out result1); // "ABC\n", "C" io.Scanf("%*cB%c", out result1); | |