Add format to scanf : Console Read Int « Console « C / ANSI-C






Add format to scanf

  
#include <stdio.h>

int main(void)
{
  int i, j;

  printf("Enter an integer: ");
  scanf("%3d %d", &i, &j);
  printf("%d %d", i, j);

  return 0;
}


           
       








Related examples in the same category

1.Demonstrates how to read a number
2.Read int value from console
3. Read formatted data from stdin: how to use scanf
4.Read unsigned int, long and short from console
5.Read and write an int value from and to console