Home :: International :: Manuals :: Howto :: FAQ :: Man Pages :: Email Login

 
 

  next up previous contents
Next: 8.2 The Termcap Library Up: 8.1 I/O Function in Previous: 8.1.1 Formatted Output

8.1.2 Formatted Input

 

Just as printf(...) is used for formatted output you can use scanf(...) for formatted input.

  • int fscanf(FILE *stream, const char *format, ...)  
    fscanf(...) reads from stream and will transform the input with the rules defined in format. The results will be placed in the arguments given by ...(Note: the arguments must be pointer.). The read ends, when no more transformation rules are in format. fscanf(...) will return EOF when the first transformation reached the file end or some error occured. Otherwise it will return the number of transformed arguments.

    format can include rules on how to format the input arguments (see table 8.2 on page gif). It can also include:

    • Spaces or tabs, which are ignored.
    • any normal character (except %). The characters must be in the input on the corresponding position.
    • transformation rules, which assembled with a %, the optional character * (this will permit fscanf(...) to assign to an argument), an optional number, an optional character h, l or L (this is for the length of the target) and the transformation character.
  • int scanf(const char *format, ...)  
    The same as fscanf(stdin,...).
  • int sscanf(char *str, const char *format, ...)  
    As scanf(...), but the input comes from str.

   table47835
Table 8.2: Libc - scanf transformations



Converted on:
Fri Mar 29 14:43:04 EST 1996
 
 
 
 
Google
  Web Linuxinfor   
 

Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account

Document on this page is part of "e". See Index Page for more info about Authorship and Copyright.

1999-2008 Linuxinfor.com. No rights reserved.