


      SSSSCCCCAAAANNNNFFFF((((3333SSSS))))                   ((((UUUUNNNNIIIIXXXX 5555....0000))))                  SSSSCCCCAAAANNNNFFFF((((3333SSSS))))



      NNNNAAAAMMMMEEEE
           scanf, fscanf, sscanf - convert formatted input

      SSSSYYYYNNNNTTTTAAAAXXXX
           ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>

           iiiinnnntttt ssssccccaaaannnnffff ((((ffffoooorrrrmmmmaaaatttt [ ,,,, pointer ] ...  ))))
           cccchhhhaaaarrrr ****ffffoooorrrrmmmmaaaatttt;;;;

           iiiinnnntttt ffffssssccccaaaannnnffff ((((ssssttttrrrreeeeaaaammmm,,,, ffffoooorrrrmmmmaaaatttt [ ,,,, pointer ] ...  ))))
           FFFFIIIILLLLEEEE ****ssssttttrrrreeeeaaaammmm;;;;
           cccchhhhaaaarrrr ****ffffoooorrrrmmmmaaaatttt;;;;

           iiiinnnntttt ssssssssccccaaaannnnffff ((((ssss,,,, ffffoooorrrrmmmmaaaatttt [ ,,,, pointer ] ...  ))))
           cccchhhhaaaarrrr ****ssss,,,, ****ffffoooorrrrmmmmaaaatttt;;;;

      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
           _S_c_a_n_f reads from the standard input stream _s_t_d_i_n.  _F_s_c_a_n_f
           reads from the named input _s_t_r_e_a_m.  _S_s_c_a_n_f reads from the
           character string _s.  Each function reads characters,
           interprets them according to a format, and stores the
           results in its arguments.  Each expects, as arguments, a
           control string _f_o_r_m_a_t described below, and a set of _p_o_i_n_t_e_r
           arguments indicating where the converted input should be
           stored.

           The control string usually contains conversion
           specifications, which are used to direct interpretation of
           input sequences.  The control string may contain:

           1. White-space characters (blanks, tabs, new-lines, or
              form-feeds) which, except in two cases described below,
              cause input to be read up to the next non-white-space
              character.
           2. An ordinary character (not %%%%), which must match the next
              character of the input stream.
           3. Conversion specifications, consisting of the character %%%%,
              an optional assignment suppressing character ****, an
              optional numerical maximum field width, an optional llll or
              hhhh indicating the size of the receiving variable, and a
              conversion code.

           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.




      Page 1                                                   (9010-E)






      SSSSCCCCAAAANNNNFFFF((((3333SSSS))))                   ((((UUUUNNNNIIIIXXXX 5555....0000))))                  SSSSCCCCAAAANNNNFFFF((((3333SSSS))))



           The conversion code 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 should be given.  The following conversion codes
           are legal:

           %%%%    a single %%%% is expected in the input at this point; no
                assignment is done.
           dddd    a decimal integer is expected; the corresponding
                argument should be an integer pointer.
           uuuu    an unsigned decimal integer is expected; the
                corresponding argument should be an unsigned integer
                pointer.
           oooo    an octal integer is expected; the corresponding
                argument should be an integer pointer.
           xxxx    a hexadecimal integer is expected; the corresponding
                argument should be an integer pointer.
           eeee,ffff,gggg
                a floating point number is expected; the next field is
                converted accordingly and stored through the
                corresponding argument, which should be a pointer to a
                _f_l_o_a_t.  The input format for floating point numbers is
                an optionally signed string of digits, possibly
                containing a decimal point, followed by an optional
                exponent field consisting of an EEEE or an eeee, followed by
                an optionally signed integer.
           ssss    a character string is expected; the corresponding
                argument should be a character pointer pointing to an
                array of characters large enough to accept the string
                and a terminating \\\\0000, which will be added
                automatically.  The input field is terminated by a
                white-space character.
           cccc    a character is expected; the corresponding argument
                should be a character pointer.  The normal skip over
                white space is suppressed in this case; to read the
                next non-space character, use %%%%1111ssss.  If a field width is
                given, the corresponding argument should refer to a
                character array; the indicated number of characters is
                read.
           [[[[    indicates string data and the normal skip over leading
                white space is suppressed.  The left bracket is
                followed by a set of characters, which we will call the
                _s_c_a_n_s_e_t, 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 _n_o_t 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
                _f_i_r_s_t-_l_a_s_t, thus [0123456789] may be expressed [0-9].



      Page 2                                                   (9010-E)






      SSSSCCCCAAAANNNNFFFF((((3333SSSS))))                   ((((UUUUNNNNIIIIXXXX 5555....0000))))                  SSSSCCCCAAAANNNNFFFF((((3333SSSS))))



                Using this convention, _f_i_r_s_t must be lexically less
                than or equal to _l_a_s_t, 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 preceded 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 \\\\0000, which will be
                added automatically.

           The conversion characters dddd, uuuu, oooo, and xxxx may be preceded by
           llll or hhhh to indicate that a pointer to lllloooonnnngggg or to sssshhhhoooorrrrtttt rather
           than to iiiinnnntttt is in the argument list.  Similarly, the
           conversion characters eeee ,,,, ffff ,,,, and gggg may be preceded by llll to
           indicate that a pointer to ddddoooouuuubbbblllleeee rather than to ffffllllooooaaaatttt is in
           the argument list.

           _S_c_a_n_f conversion terminates at EEEEOOOOFFFF, at the end of the
           control string, or when an input character conflicts with
           the control string.  In the latter case, the offending
           character is left unread in the input stream.

           _S_c_a_n_f returns the number of successfully matched and
           assigned input items; this number can be zero in the event
           of an early conflict between an input character and the
           control string.  If the input ends before the first conflict
           or conversion, EEEEOOOOFFFF is returned.

      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
           The call:

                int i; float x; char name[50];
                scanf ("%d%f%s", &i, &x, name);

           with the input line:

                25 54.32E-1 thompson

           will assign to _i the value 22225555, to _x the value 5555....444433332222, and
           _n_a_m_e will contain tttthhhhoooommmmppppssssoooonnnn\\\\0000.  Or:

                int i; float x; char name[50];
                scanf ("%2d%f%*d %[0-9]", &i, &x, name);

           with input:

                56789 0123 56a72

           will assign 55556666 to _i, 777788889999....0000 to _x, skip 0000111122223333, and place the



      Page 3                                                   (9010-E)






      SSSSCCCCAAAANNNNFFFF((((3333SSSS))))                   ((((UUUUNNNNIIIIXXXX 5555....0000))))                  SSSSCCCCAAAANNNNFFFF((((3333SSSS))))



           string 55556666\\\\0000 in _n_a_m_e.  The next call to _g_e_t_c_h_a_r (see
           _g_e_t_c(3S)) will return aaaa.

      SSSSEEEEEEEE AAAALLLLSSSSOOOO
           atof(3C), getc(3S), printf(3S), strtol(3C).

      NNNNOOOOTTTTEEEE
           Trailing white space (including a new-line) is left unread
           unless matched in the control string.

      DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
           These functions return EEEEOOOOFFFF on end of input and a short count
           for missing or illegal data items.

      BBBBUUUUGGGGSSSS
           The success of literal matches and suppressed assignments is
           not directly determinable.






































      Page 4                                                   (9010-E)



