/* File: scan8.c Another solution to the scanf problem */ #include main() { int d = 0, r = 0 ; int ch ; printf("Enter an integer: ") ; while (1) { r = scanf("%d", &d) ; fflush(stdin) ; if (r == 1) break ; printf("Try again, enter an integer: ") ; } printf("r = %d d = %d\n", r, d) ; printf("Enter another integer: ") ; r = scanf("%d", &d) ; printf("r = %d d = %d\n", r, d) ; }