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; }