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

Format input from a file stream
#iinncclluuddee <ssttddiioo.hh>
iinntt ffssccaannff(_f_p, _f_o_r_m_a_t, _a_r_g_1, ... _a_r_g_N)
FFIILLEE *_f_p; cchhaarr *_f_o_r_m_a_t;
[_d_a_t_a _t_y_p_e] *_a_r_g_1, ... *_a_r_g_N;

ffssccaannff() reads the file stream pointed to by _f_p, and uses the string _f_o_r_m_a_t
to format  the arguments _a_r_g_1 through  _a_r_g_N, each of which  must point to a
variable of the appropriate data type.

ffssccaannff()  returns either  the number  of  arguments matched,  or EOF  if no
arguments matched.

For more information on ffssccaannff()'s conversion codes, see ssccaannff().

_E_x_a_m_p_l_e
The following  example uses ffpprriinnttff() to  write some data into  a file, and
then reads it back using ffssccaannff().

#include <stdio.h>

main ()
{
    FILE *fp;
    char let[4];

    /* open file into write/read mode */
    if ((fp = fopen("tmpfile", "wr")) == NULL) {
        printf("Cannot open 'tmpfile'\n");
        exit(1);
    }

    /* write a string of chars into file */
    fprintf(fp, "1234");

    /* move file pointer back to beginning of file */
    rewind(fp);

    /* read and print data from file */
    fscanf(fp, "%c %c %c %c",
        &let[0], &let[1], &let[2], &let[3]);
    printf("%c %c %c %c\n",
        let[3], let[2], let[1], let[0]);
}

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

_N_o_t_e_s
Because C does not perform type  checking, it is essential that an argument
match its  specification.  For that reason,  ffs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 previously written out with ffpprriinnttff().
