Ok, so how do you tell the difference between entering "0" and "abcd"?
You have to use the return value from scanf() - yes, I know, most peopel use scanf() without looking at the returned value, but it's still being returned, and it returns "How many items were successfully read", so for example:That would print r=1 if x is filled in, and r=0 if x s not filled in. What value it "gives" on x when it's not filled in is whatever value x had before calling scanf.Code:int x; int r; for(;;) { x = 12345678; r = scanf("%d", &x); printf("x= %d, r=%d\n", x, r); }
--
Mats