C Tutorial/stdio.h/scanf


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

scanf

Item Value Header file stdio.h Declaration int scanf(const char *format, ...); Function read input.

The control string pointed to by format consists of three classifications of characters:

  1. Format specifiers
  2. White-space characters
  3. Non-white-space characters

The scanf() Format Specifiers

Code Meaning %a Read a floating-point value (C99 only) %A Same as %a (C99 only) %c Read a single character %d Read a decimal integer %i Read an integer in either decimal, octal, or hexadecimal format %e Read a floating-point number %E Same as %e %f Read a floating-point number %F Same as %f (C99 only) %g Read a floating-point number %G Same as %g %o Read an octal number %s Read a string %x Read a hexadecimal number %X Same as %x %p Read a pointer %n Receive an integer value equal to the number of characters read so far %u Read an unsigned decimal integer %[ ] Scan for a set of characters %% Read a percent sign