C Tutorial/printf scanf/scanf field width

Материал из 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