📄 scanfs.gml
字号:
.newtext Format Control String:
The format control string consists of zero or more
.us format directives
that specify acceptable input file data.
Subsequent arguments are pointers to various types of objects that are
assigned values as the format string is processed.
.np
A format directive can be a sequence of one or more white-space
characters, an
.us ordinary character,
or a
.us conversion specifier.
An ordinary character in the format string is any character, other
than a white-space character or the percent character (%), that is not
part of a conversion specifier.
A conversion specifier is a sequence of characters in the format
string that begins with a percent character (%) and is followed, in
sequence, by the following:
.begbull
.bull
an optional assignment suppression indicator: the asterisk character
(*);
.bull
an optional decimal integer that specifies the
.us maximum field width
to be scanned for the conversion;
.if &farfnc ne 0 .do begin
.bull
an optional
.us pointer-type
specification: one of "N" or "W";
.do end
.bull
an optional
.us type length
specification: one of "hh", "h", "l", "ll", "j", "z", "t", "L" or "I64";
.bull
a character that specifies the type of conversion to be performed: one
of the characters "cCdeEfFgGinopsSuxX[".
.endbull
.np
As each format directive in the format string is processed, the
directive may successfully complete, fail because of a lack of input
data, or fail because of a matching error as defined by the particular
directive.
If end-of-file is encountered on the input data before any characters
that match the current directive have been processed (other than
leading white-space where permitted), the directive fails for lack of
data.
If end-of-file occurs after a matching character has been processed,
the directive is completed (unless a matching error occurs), and the
function returns without processing the next directive.
If a directive fails because of an input character mismatch, the
character is left unread in the input stream.
Trailing white-space characters, including new-line characters, are
not read unless matched by a directive.
When a format directive fails, or the end of the format string is
encountered, the scanning is completed and the function returns.
.np
When one or more white-space characters (space "&sysrb", horizontal
tab "\t", vertical tab "\v", form feed "\f", carriage return "\r", new
line or linefeed "\n") occur in the format string, input data up to
the first non-white-space character is read, or until no more data
remains.
If no white-space characters are found in the input data, the scanning
is complete and the function returns.
.np
An ordinary character in the format string is expected to match the
same character in the input stream.
.np
A conversion specifier in the format string is processed as follows:
.begbull
.bull
for conversion types other than "[", "c", "C" and "n", leading
white-space characters are skipped
.bull
for conversion types other than "n", all input characters, up to any
specified maximum field length, that can be matched by the conversion
type are read and converted to the appropriate type of value; the
character immediately following the last character to be matched is
left unread; if no characters are matched, the format directive fails
.bull
unless the assignment suppression indicator ("*") was specified, the
result of the conversion is assigned to the object pointed to by the
next unused argument (if assignment suppression was specified, no
argument is skipped); the arguments must correspond in number, type
and order to the conversion specifiers in the format string
.endbull
.if &farfnc ne 0 .do begin
.np
A pointer-type specification is used to indicate the type of pointer
used to locate the next argument to be scanned:
.begnote $setptnt 5
.note W
pointer is a far pointer
.note N
pointer is a near pointer
.endnote
.np
The pointer-type specification is only effective on platforms that use
a segmented memory model, although it is always recognized.
.do end
.np
The pointer type defaults to that used for data in the memory model
for which the program has been compiled.
.np
A type length specifier affects the conversion as follows:
.begbull
.bull
"hh" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id signed char
or
.id unsigned char.
.bull
"hh" causes an "n" (read length assignment) operation to assign the
number of characters that have been read to an object of type
.id signed char.
.bull
"h" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id short int
or
.id unsigned short int.
.bull
.ix 'fixed-point'
"h" causes an "f" conversion to assign a fixed-point number to an object
of type
.id long
consisting of a 16-bit signed integer part and a 16-bit unsigned
fractional part.
The integer part is in the high 16 bits and the fractional part is in
the low 16 bits.
.millust begin
struct fixpt {
unsigned short fraction; /* Intel architecture! */
signed short integral;
};
struct fixpt foo1 =
{ 0x8000, 1234 }; /* represents 1234.5 */
struct fixpt foo2 =
{ 0x8000, -1 }; /* represents -0.5 (-1+.5) */
.millust end
.bull
"h" causes an "n" (read length assignment) operation to assign the
number of characters that have been read to an object of type
.id short int.
.if &'length(&wfunc.) ne 0 .do begin
.bull
"h" causes an "s" operation to convert the input string to an ASCII
character string.
For &func, this specifier is redundant.
For &wfunc, this specifier is required if the wide character input
string is to be converted to an ASCII character string; otherwise it
will not be converted.
.do end
.if &'length(&ufunc.) ne 0 .do begin
.bull
"h" causes an "s" operation to convert the input string to an ASCII
character string.
For &func, this specifier is redundant.
For &ufunc, this specifier is required if the Unicode input string is
to be converted to an ASCII character string; otherwise it will not be
converted.
.do end
.bull
"l" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id long int
or
.id unsigned long int.
.bull
"l" causes an "n" (read length assignment) operation to assign the
number of characters that have been read to an object of type
.id long int.
.bull
"l" causes an "e", "f" or "g" (floating-point) conversion to assign
the converted value to an object of type
.id double.
.if &'length(&wfunc.) ne 0 .do begin
.bull
"l" or "w" cause an "s" operation to convert the input string to a
wide character string.
For &func, this specifier is required if the input ASCII string is to
be converted to a wide character string; otherwise it will not be
converted.
.do end
.if &'length(&ufunc.) ne 0 .do begin
.bull
"l" or "w" cause an "s" operation to convert the input string to a
16-bit Unicode character string.
For &func, this specifier is required if the input ASCII string is to
be converted to a 16-bit Unicode character string; otherwise it will
not be converted.
.do end
.bull
"ll" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id long long
or
.id unsigned long long
(e.g., %lld).
.bull
"ll" causes an "n" (read length assignment) operation to assign the
number of characters that have been read to an object of type
.id long long int.
.bull
.ix 'intmax_t'
.ix 'uintmax_t'
"j" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id intmax_t
or
.id uintmax_t.
.bull
"j" causes an "n" (read length assignment) operation to assign the
number of characters that have been read to an object of type
.id intmax_t.
.bull
.ix 'size_t'
"z" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id size_t
or the corresponding signed integer type.
.bull
"z" causes an "n" (read length assignment) operation to assign the
number of characters that have been read to an object of signed integer
type corresponding to
.id size_t.
.bull
.ix 'ptrdiff_t'
"t" causes a "d", "i", "o", "u" or "x" (integer) conversion to
assign the converted value to an object of type
.id ptrdiff_t
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -