home *** CD-ROM | disk | FTP | other *** search
-
- SCANF(3) UNIX Programmer's Manual SCANF(3)
-
- NNAAMMEE
- ssccaannff, ffssccaannff, ssssccaannff, vvssccaannff, vvssssccaannff, vvffssccaannff - input format conversion
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ssttddiioo..hh>>
-
- _i_n_t
- ssccaannff(_c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _._._.)
-
- _i_n_t
- ffssccaannff(_F_I_L_E _*_s_t_r_e_a_m, _c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _._._.)
-
- _i_n_t
- ssssccaannff(_c_o_n_s_t _c_h_a_r _*_s_t_r, _c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _._._.)
-
- ##iinncclluuddee <<ssttddaarrgg..hh>>
-
- _i_n_t
- vvssccaannff(_c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _v_a___l_i_s_t _a_p)
-
- _i_n_t
- vvssssccaannff(_c_o_n_s_t _c_h_a_r _*_s_t_r, _c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _v_a___l_i_s_t _a_p)
-
- _i_n_t
- vvffssccaannff(_F_I_L_E _*_s_t_r_e_a_m, _c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _v_a___l_i_s_t _a_p)
-
- DDEESSCCRRIIPPTTIIOONN
- The ssccaannff() family of functions scans input according to a _f_o_r_m_a_t as de
- scribed below. This format may contain _c_o_n_v_e_r_s_i_o_n _s_p_e_c_i_f_i_e_r_s; the re
- sults from such conversions, if any, are stored through the _p_o_i_n_t_e_r argu
- ments. The ssccaannff() function reads input from the standard input stream
- _s_t_d_i_n, ffssccaannff() reads input from the stream pointer _s_t_r_e_a_m, and ssssccaannff()
- reads its input from the character string pointed to by _s_t_r. The
- vvffssccaannff() function is analogous to vfprintf(3) and reads input from the
- stream pointer _s_t_r_e_a_m using a variable argument list of pointers (see
- stdarg(3)). The vvssccaannff() function scans a variable argument list from
- the standard input and the vvssssccaannff() function scans it from a string;
- these are analogous to the vvpprriinnttff() and vvsspprriinnttff() functions respective
- ly. Each successive _p_o_i_n_t_e_r argument must correspond properly with each
- successive conversion specifier (but see `suppression' below). All con
- versions are introduced by the %% (percent sign) character. The _f_o_r_m_a_t
- string may also contain other characters. White space (such as blanks,
- tabs, or newlines) in the _f_o_r_m_a_t string match any amount of white space,
- including none, in the input. Everything else matches only itself.
- Scanning stops when an input character does not match such a format char
- acter. Scanning also stops when an input conversion cannot be made (see
- below).
-
- CCOONNVVEERRSSIIOONNSS
- Following the %% character introducing a conversion there may be a number
- of _f_l_a_g characters, as follows:
-
- ** Suppresses assignment. The conversion that follows occurs as
- usual, but no pointer is used; the result of the conversion is
- simply discarded.
-
- hh Indicates that the conversion will be one of ddiioouuxx or nn and the
- next pointer is a pointer to a _s_h_o_r_t _i_n_t (rather than _i_n_t).
-
- ll Indicates either that the conversion will be one of ddiioouuxx or nn
- and the next pointer is a pointer to a _l_o_n_g _i_n_t (rather than
- _i_n_t), or that the conversion will be one of eeffgg and the next
-
- pointer is a pointer to _d_o_u_b_l_e (rather than _f_l_o_a_t).
-
- LL Indicates that the conversion will be eeffgg and the next pointer is
- a pointer to _l_o_n_g _d_o_u_b_l_e. (This type is not implemented; the LL
- flag is currently ignored.)
-
- In addition to these flags, there may be an optional maximum field width,
- expressed as a decimal integer, between the %% and the conversion. If no
- width is given, a default of `infinity' is used (with one exception, be
- low); otherwise at most this many characters are scanned in processing
- the conversion. Before conversion begins, most conversions skip white
- space; this white space is not counted against the field width.
-
- The following conversions are available:
-
- %% Matches a literal `%'. That is, `%%' in the format string matches
- a single input `%' character. No conversion is done, and assign
- ment does not occur.
-
- dd Matches an optionally signed decimal integer; the next pointer must
- be a pointer to _i_n_t.
-
- DD Equivalent to ld; this exists only for backwards compatibility.
-
- ii Matches an optionally signed integer; the next pointer must be a
- pointer to _i_n_t. The integer is read in base 16 if it begins with
- `0x' or `0X', in base 8 if it begins with `0', and in base 10 oth
- erwise. Only characters that correspond to the base are used.
-
- oo Matches an octal integer; the next pointer must be a pointer to
- _u_n_s_i_g_n_e_d _i_n_t.
-
- OO Equivalent to lo; this exists for backwards compatibility.
-
- uu Matches an optionally signed decimal integer; the next pointer must
- be a pointer to _u_n_s_i_g_n_e_d _i_n_t.
-
- xx Matches an optionally a signed hexadecimal integer; the next point
- er must be a pointer to _u_n_s_i_g_n_e_d _i_n_t.
-
- XX Equivalent to llxx; this violates the ANSI C3.1591989 (``ANSI C''),
- but is backwards compatible with previous UNIX systems.
-
- ff Matches an optionally signed floatingpoint number; the next point
- er must be a pointer to _f_l_o_a_t.
-
- ee Equivalent to ff.
-
- gg Equivalent to ff.
-
- EE Equivalent to llff; this violates the ANSI C3.1591989 (``ANSI C''),
- but is backwards compatible with previous UNIX systems.
-
- FF Equivalent to llff; this exists only for backwards compatibility.
-
- ss Matches a sequence of nonwhitespace characters; the next pointer
- must be a pointer to _c_h_a_r, and the array must be large enough to
- accept all the sequence and the terminating NUL character. The in
- put string stops at white space or at the maximum field width,
- whichever occurs first.
-
- cc Matches a sequence of _w_i_d_t_h count characters (default 1); the next
- pointer must be a pointer to _c_h_a_r, and there must be enough room
- for all the characters (no terminating NUL is added). The usual
- skip of leading white space is suppressed. To skip white space
-
- first, use an explicit space in the format.
-
- [[ Matches a nonempty sequence of characters from the specified set of
- accepted characters; the next pointer must be a pointer to _c_h_a_r,
- and there must be enough room for all the characters in the string,
- plus a terminating NUL character. The usual skip of leading white
- space is suppressed. The string is to be made up of characters in
- (or not in) a particular set; the set is defined by the characters
- between the open bracket [ character and a close bracket ] charac
- ter. The set _e_x_c_l_u_d_e_s those characters if the first character af
- ter the open bracket is a circumflex ^^. To include a close bracket
- in the set, make it the first character after the open bracket or
- the circumflex; any other position will end the set. The hyphen
- character is also special; when placed between two other charac
- ters, it adds all intervening characters to the set. To include a
- hyphen, make it the last character before the final close bracket.
- For instance, `[^]09]' means the set `everything except close
- bracket, zero through nine, and hyphen'. The string ends with the
- appearance of a character not in the (or, with a circumflex, in)
- set or when the field width runs out.
-
- pp Matches a pointer value (as printed by `%p' in printf(3)); the
- next pointer must be a pointer to _v_o_i_d.
-
- nn Nothing is expected; instead, the number of characters consumed
- thus far from the input is stored through the next pointer, which
- must be a pointer to _i_n_t. This is _n_o_t a conversion, although it can
- be suppressed with the ** flag.
-
- For backwards compatibility, other conversion characters (except `\0')
- are taken as if they were `%d' or, if uppercase, `%ld', and a `conver
- sion' of `%\0' causes an immediate return of EOF. The FF and XX conversions
- will be changed in the future to conform to the ANSI C standard, after
- which they will act like ff and xx respectively.
-
- RREETTUURRNN VVAALLUUEESS
- These functions return the number of input items assigned, which can be
- fewer than provided for, or even zero, in the event of a matching fail
- ure. Zero indicates that, while there was input available, no conver
- sions were assigned; typically this is due to an invalid input character,
- such as an alphabetic character for a `%d' conversion. The value EOF is
- returned if an input failure occurs before any conversion such as an end
- offile occurs. If an error or endoffile occurs after conversion has
- begun, the number of conversions which were successfully completed is re
- turned.
-
- SSEEEE AALLSSOO
- strtol(3), strtoul(3), getc(3), printf(3)
-
- SSTTAANNDDAARRDDSS
- The functions ffssccaannff(), ssccaannff(), and ssssccaannff() conform to ANSI C3.1591989
- (``ANSI C'').
-
- HHIISSTTOORRYY
- The functions vvssccaannff(), vvssssccaannff() and vvffssccaannff() are new to this release.
-
- BBUUGGSS
- The current situation with %%FF and %%XX conversions is unfortunate.
-
- All of the backwards compatibility formats will be removed in the future.
-
- BSD Experimental June 29, 1991 3
-
-
-
-
-