The more I think about it, the following is better. No more buffer overflow problem.
#include <stdio.h> int main() { int test; int result; int j; for(j = 0; j < 10; j++) { while ( scanf("%*[^0-9-]") ); result = scanf("%d", &test); if ( ! result) printf("Error\n"); else printf("Success: %d\n", test); } }