ssssccaannff() -- STDIO Function (libc)

Format a string
#iinncclluuddee <ssttddiioo.hh>
iinntt ssssccaannff(_s_t_r_i_n_g, _f_o_r_m_a_t [, _a_r_g ] ...)
cchhaarr *_s_t_r_i_n_g; cchhaarr *_f_o_r_m_a_t;

ssssccaannff() reads the argument _s_t_r_i_n_g, and uses _f_o_r_m_a_t to specify a format for
each  _a_r_g, each  of  which must  be  a pointer.   For  more information  on
ssssccaannff()'s conversion codes, see ssccaannff().

_E_x_a_m_p_l_e
This example  uses sspprriinnttff()  to create  a string, and  then reads  it with
ssssccaannff().  It also illustrates a common problem with this routine.

#include <stdio.h>

main()
{
    char string[80];
    char s1[10], s2[10];

    sprintf(string, "123456789012345678901234567890");
    sscanf(string, "%9c", s1);
    sscanf(string, "%10c", s2);

    printf("\n%s is the string\n", string);
    printf("%s: first 9 characters in string\n", s1);
    printf("%s: first 19 characters in string\n", s2);
}

_S_e_e _A_l_s_o
ffssccaannff(), lliibbcc, ssccaannff()
ANSI Standard, section 7.9.6.6
POSIX Standard, section 8.1

_D_i_a_g_n_o_s_t_i_c_s
ssssccaannff() returns  the number  of arguments filled.   It returns zero  if no
arguments can be filled or if an error occurs.

_N_o_t_e_s
Because C does not perform type checking, an argument must match its format
specification.  ssssccaannff()  is best  used only to  process data that  you are
certain are in the correct data format, such as data that were written with
sspprriinnttff().

ssssccaannff()  is difficult  to use  correctly, and  incorrect usage  can create
serious bugs in programs.  It is recommended that you use ssttrrttookk() instead.
