home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / ixemul-39.47-env-bin.lha / man / cat3 / scanf.0 < prev    next >
Text File  |  1993-12-07  |  11KB  |  199 lines

  1.  
  2. SCANF(3)                   UNIX Programmer's Manual                   SCANF(3)
  3.  
  4. NNAAMMEE
  5.      ssccaannff, ffssccaannff, ssssccaannff, vvssccaannff, vvssssccaannff, vvffssccaannff - input format conversion
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssttddiioo..hh>>
  9.  
  10.      _i_n_t
  11.      ssccaannff(_c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _._._.)
  12.  
  13.      _i_n_t
  14.      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, _._._.)
  15.  
  16.      _i_n_t
  17.      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, _._._.)
  18.  
  19.      ##iinncclluuddee <<ssttddaarrgg..hh>>
  20.  
  21.      _i_n_t
  22.      vvssccaannff(_c_o_n_s_t _c_h_a_r _*_f_o_r_m_a_t, _v_a___l_i_s_t _a_p)
  23.  
  24.      _i_n_t
  25.      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)
  26.  
  27.      _i_n_t
  28.      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)
  29.  
  30. DDEESSCCRRIIPPTTIIOONN
  31.      The ssccaannff() family of functions scans input according to a _f_o_r_m_a_t as de­
  32.      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­
  33.      sults from such conversions, if any, are stored through the _p_o_i_n_t_e_r argu­
  34.      ments.  The ssccaannff() function reads input from the standard input stream
  35.      _s_t_d_i_n, ffssccaannff() reads input from the stream pointer _s_t_r_e_a_m, and ssssccaannff()
  36.      reads its input from the character string pointed to by _s_t_r. The
  37.      vvffssccaannff() function is analogous to vfprintf(3) and reads input from the
  38.      stream pointer _s_t_r_e_a_m using a variable argument list of pointers (see
  39.      stdarg(3)).  The vvssccaannff() function scans a variable argument list from
  40.      the standard input and the vvssssccaannff() function scans it from a string;
  41.      these are analogous to the vvpprriinnttff() and vvsspprriinnttff() functions respective­
  42.      ly.  Each successive _p_o_i_n_t_e_r argument must correspond properly with each
  43.      successive conversion specifier (but see `suppression' below).  All con­
  44.      versions are introduced by the %% (percent sign) character.  The _f_o_r_m_a_t
  45.      string may also contain other characters.  White space (such as blanks,
  46.      tabs, or newlines) in the _f_o_r_m_a_t string match any amount of white space,
  47.      including none, in the input.  Everything else matches only itself.
  48.      Scanning stops when an input character does not match such a format char­
  49.      acter.  Scanning also stops when an input conversion cannot be made (see
  50.      below).
  51.  
  52. CCOONNVVEERRSSIIOONNSS
  53.      Following the %% character introducing a conversion there may be a number
  54.      of _f_l_a_g characters, as follows:
  55.  
  56.      **       Suppresses assignment.  The conversion that follows occurs as
  57.              usual, but no pointer is used; the result of the conversion is
  58.              simply discarded.
  59.  
  60.      hh       Indicates that the conversion will be one of ddiioouuxx or nn and the
  61.              next pointer is a pointer to a _s_h_o_r_t _i_n_t (rather than _i_n_t).
  62.  
  63.      ll       Indicates either that the conversion will be one of ddiioouuxx or nn
  64.              and the next pointer is a pointer to a _l_o_n_g _i_n_t (rather than
  65.              _i_n_t), or that the conversion will be one of eeffgg and the next
  66.  
  67.              pointer is a pointer to _d_o_u_b_l_e (rather than _f_l_o_a_t).
  68.  
  69.      LL       Indicates that the conversion will be eeffgg and the next pointer is
  70.              a pointer to _l_o_n_g _d_o_u_b_l_e. (This type is not implemented; the LL
  71.              flag is currently ignored.)
  72.  
  73.      In addition to these flags, there may be an optional maximum field width,
  74.      expressed as a decimal integer, between the %% and the conversion.  If no
  75.      width is given, a default of `infinity' is used (with one exception, be­
  76.      low); otherwise at most this many characters are scanned in processing
  77.      the conversion.  Before conversion begins, most conversions skip white
  78.      space; this white space is not counted against the field width.
  79.  
  80.      The following conversions are available:
  81.  
  82.      %%     Matches a literal `%'.  That is, `%%' in the format string matches
  83.            a single input `%' character.  No conversion is done, and assign­
  84.            ment does not occur.
  85.  
  86.      dd     Matches an optionally signed decimal integer; the next pointer must
  87.            be a pointer to _i_n_t.
  88.  
  89.      DD     Equivalent to ld;  this exists only for backwards compatibility.
  90.  
  91.      ii     Matches an optionally signed integer; the next pointer must be a
  92.            pointer to _i_n_t. The integer is read in base 16 if it begins with
  93.            `0x' or `0X', in base 8 if it begins with `0', and in base 10 oth­
  94.            erwise.  Only characters that correspond to the base are used.
  95.  
  96.      oo     Matches an octal integer; the next pointer must be a pointer to
  97.            _u_n_s_i_g_n_e_d _i_n_t.
  98.  
  99.      OO     Equivalent to lo;  this exists for backwards compatibility.
  100.  
  101.      uu     Matches an optionally signed decimal integer; the next pointer must
  102.            be a pointer to _u_n_s_i_g_n_e_d _i_n_t.
  103.  
  104.      xx     Matches an optionally a signed hexadecimal integer; the next point­
  105.            er must be a pointer to _u_n_s_i_g_n_e_d _i_n_t.
  106.  
  107.      XX     Equivalent to llxx; this violates the ANSI C3.159­1989 (``ANSI C''),
  108.            but is backwards compatible with previous UNIX systems.
  109.  
  110.      ff     Matches an optionally signed floating­point number; the next point­
  111.            er must be a pointer to _f_l_o_a_t.
  112.  
  113.      ee     Equivalent to ff.
  114.  
  115.      gg     Equivalent to ff.
  116.  
  117.      EE     Equivalent to llff; this violates the ANSI C3.159­1989 (``ANSI C''),
  118.            but is backwards compatible with previous UNIX systems.
  119.  
  120.      FF     Equivalent to llff; this exists only for backwards compatibility.
  121.  
  122.      ss     Matches a sequence of non­white­space characters; the next pointer
  123.            must be a pointer to _c_h_a_r, and the array must be large enough to
  124.            accept all the sequence and the terminating NUL character.  The in­
  125.            put string stops at white space or at the maximum field width,
  126.            whichever occurs first.
  127.  
  128.      cc     Matches a sequence of _w_i_d_t_h count characters (default 1); the next
  129.            pointer must be a pointer to _c_h_a_r, and there must be enough room
  130.            for all the characters (no terminating NUL is added).  The usual
  131.            skip of leading white space is suppressed.  To skip white space
  132.  
  133.            first, use an explicit space in the format.
  134.  
  135.      [[     Matches a nonempty sequence of characters from the specified set of
  136.            accepted characters; the next pointer must be a pointer to _c_h_a_r,
  137.            and there must be enough room for all the characters in the string,
  138.            plus a terminating NUL character.  The usual skip of leading white
  139.            space is suppressed.  The string is to be made up of characters in
  140.            (or not in) a particular set; the set is defined by the characters
  141.            between the open bracket [ character and a close bracket ] charac­
  142.            ter.  The set _e_x_c_l_u_d_e_s those characters if the first character af­
  143.            ter the open bracket is a circumflex ^^. To include a close bracket
  144.            in the set, make it the first character after the open bracket or
  145.            the circumflex; any other position will end the set.  The hyphen
  146.            character ­­ is also special; when placed between two other charac­
  147.            ters, it adds all intervening characters to the set.  To include a
  148.            hyphen, make it the last character before the final close bracket.
  149.            For instance, `[^]0­9­]' means the set `everything except close
  150.            bracket, zero through nine, and hyphen'.  The string ends with the
  151.            appearance of a character not in the (or, with a circumflex, in)
  152.            set or when the field width runs out.
  153.  
  154.      pp     Matches a pointer value (as printed by `%p' in printf(3));  the
  155.            next pointer must be a pointer to _v_o_i_d.
  156.  
  157.      nn     Nothing is expected; instead, the number of characters consumed
  158.            thus far from the input is stored through the next pointer, which
  159.            must be a pointer to _i_n_t. This is _n_o_t a conversion, although it can
  160.            be suppressed with the ** flag.
  161.  
  162.      For backwards compatibility, other conversion characters (except `\0')
  163.      are taken as if they were `%d' or, if uppercase, `%ld', and a `conver­
  164.      sion' of `%\0' causes an immediate return of EOF. The FF and XX conversions
  165.      will be changed in the future to conform to the ANSI C standard, after
  166.      which they will act like ff and xx respectively.
  167.  
  168. RREETTUURRNN VVAALLUUEESS
  169.      These functions return the number of input items assigned, which can be
  170.      fewer than provided for, or even zero, in the event of a matching fail­
  171.      ure.  Zero indicates that, while there was input available, no conver­
  172.      sions were assigned; typically this is due to an invalid input character,
  173.      such as an alphabetic character for a `%d' conversion.  The value EOF is
  174.      returned if an input failure occurs before any conversion such as an end­
  175.      of­file occurs. If an error or end­of­file occurs after conversion has
  176.      begun, the number of conversions which were successfully completed is re­
  177.      turned.
  178.  
  179. SSEEEE AALLSSOO
  180.      strtol(3),  strtoul(3),  getc(3),  printf(3)
  181.  
  182. SSTTAANNDDAARRDDSS
  183.      The functions ffssccaannff(), ssccaannff(), and ssssccaannff() conform to ANSI C3.159­1989
  184.      (``ANSI C'').
  185.  
  186. HHIISSTTOORRYY
  187.      The functions vvssccaannff(), vvssssccaannff() and vvffssccaannff() are new to this release.
  188.  
  189. BBUUGGSS
  190.      The current situation with %%FF and %%XX conversions is unfortunate.
  191.  
  192.      All of the backwards compatibility formats will be removed in the future.
  193.  
  194. BSD Experimental                 June 29, 1991                               3
  195.  
  196.  
  197.  
  198.  
  199.