|
Otros manuales para este modelo:
Resumen del manual
HP C/iX Library Function Descriptions
scanf
(Ten spaces followed by "Hello, there!"; the double quotes are added for clarity). If you use
%c, you get a space character. However, if you use %1s, you get "H" (the first nonspace
character in the input).
The [ conversion character also reads a character string from stdin. However, you should
use this character when a string is not to be delimited by space characters. The left bracket
is followed by a list of characters, and is terminated by a right bracket. If the first
character after the left bracket is a circumflex (^), characters are read from stdin until a
character is read which matches one of the characters between the brackets. If the first
character is not a circumflex, characters are read from stdin until a character not
occurring between the brackets is found. The corresponding item in the item list must
refer to a character array large enough to hold the characters read, plus a terminating null
character which is added automatically. In some implementations, a minus sign (-) may
specify a range of characters.
The three string conversion characters provide you with a complete set of string-reading
capabilities. The c conversion character can be used to read any single character, or to read
a character string when the exact number of characters in the string is known beforehand.
The s conversion character enables you to read any character string which is delimited by
space characters, and is of unknown length. Finally, the [ conversion character enables
you to read character strings that are delimited by characters other than space characters,
and which are of unknown length.
Floating-Point Conversion Characters
The e, f, and g (or E, F, and G, respectively) conversion characters read characters
from stdin until an inappropriate character is encountered, or until the number of
characters specified by the field width, if given, is exhausted (whichever comes first).
The e, f, and g characters expect data in the following form: an optionally signed string
of digits (possibly containing a decimal point), followed by an optional exponent field
consisting of an E or e followed by an optionally signed integer. Thus, an inappropriate
character is any character except +, -, ., 0 through 9, E, or e.
These floating-point conversion characters may be preceded by a lowercase L (l), to
indicate that a double value is expected rather than a float, or by an uppercase L (in
ANSI C) to indicate that a long double value is expected rather than a float. The
corresponding items in the item list for these conversion characters must be pointers to
floating-point variables of the appropriate length.
Literal Characters
Any characters included in the format which are not part of a conversion specification are
literal characters. A literal character is expected to occur in the input at exactly that point.
Note that since the percent sign is used to introduce a conversion specification, you must
type two percent signs (%%) to get a literal percent sign.
Suppose that you want to read the following line of data:
NAME: Joe Kool; AGE: 27; PROF: Elec Engr; SAL: 39550
To get the vital data, you must read two strings (containing spaces) and two integers. You
also have data that should be ignored, such as the semicolons and the identifying strings
Chapter 5
299
...Otros modelos de este manual:
Software - MPE/iX 6.5 Operating System (943.52 kb)
Software - MPE/iX 7.0 Operating System (943.52 kb)
Software - MPE/iX 7.5 Operating System (943.52 kb)