Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




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


With any suggestions or questions please feel free to contact us