C Tutorial/printf scanf/scanf field width


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++ эксперт
Перейти к: навигация, поиск

inputting data with a field width

#include <stdio.h>
int main()
{ 
   int x; 
   int y; 
   
   printf( "Enter a six digit integer: " );
   scanf( "%2d%d", &x, &y );
   printf( "The integers input were %d and %d\n", x, y );
   return 0; 
}
Enter a six digit integer: 1
2
The integers input were 1 and 2