| Did you know ... | Search Documentation: |
| char_array<-scan |
sscanf(3).
For details consult your C-library documentation. On most Unix systems
this is done using the command
man sscanf.
Below is a description of the format string as taken from the SunOs manual.
The control string usually contains conversion specifications, which are used to direct interpretation of input sequences. The control string may contain:
Conversion specifications are introduced by the character % or the
character sequence %digit$. A conversion specification directs the
conversion of the next input field; the result is placed in the variable
pointed to by the corresponding argument, unless assignment suppression
was indicated by _*_. The suppression of assignment provides a way of
describing an input field which is to be skipped. An input field is
defined as a string of non-space characters; it extends to the next
inappropriate character or until the field width, if specified, is
exhausted. For all descriptors except _[_' and c’,
white space leading an input field is ignored.
The conversion character indicates the interpretation of the input field; the corresponding pointer argument must usually be of a restricted type. For a suppressed field, no pointer argument is given. The following conversion characters are legal:
# % A single % is expected in the input at this point; no assignment is done.
The various integer formats (the result is always returned as a PCE int).
_0_' implies octal; a leading _0x_’implies
hexadecimal; otherwise, decimal.The various floating point formats. The result is passed as an instance of class real.
string_to_decimal(3),
with fortran_conventions zero.
A character. The result is returned as the ASCII (PCE int).
The string formats. The result is a PCE string object.
\0, which will be
added automatically. The input field is terminated by a white space
character.
# [ Indicates string data; the normal skip over leading white space
is suppressed. The left bracket is followed by a set of characters,
which we will call the scanset, and a right bracket; the input field is
the maximal sequence of input characters consisting entirely of
characters in the scanset. The circumflex (^), when it
appears as the first character in the scanset, serves as a complement
operator and redefines the scanset as the set of all characters not
contained in the remainder of the scanset string. There are some
conventions used in the construction of the scanset. A range of
characters may be represented by the construct first-last, thus
[0123456789] may be expressed [0-9]. Using this convention, first must
be lexically less than or equal to last, or else the dash will stand for
itself. The dash will also stand for itself whenever it is the first or
the last character in the scanset. To include the right square bracket
as an element of the scanset, it must appear as the first character
(possibly pre- ceded by a circumflex) of the scanset, and in this case
it will not be syntactically interpreted as the closing bracket. The
corresponding argument must point to a character array large enough to
hold the data field and the terminating \0, which will be
added automatically. At least one character must match for this
conversion to be considered successful.
See also class regex.