'when there are no successful assignments, I know that scanf returns 0 to indicate it, but is that the only thing it does? this is my code:
#include<stdio.h> int main(void) { int val,x; x=scanf("%d",&val); if(x==1) printf("success!"); else{ printf("try again\n"); scanf("%d",&val); } return 0; }
if I enter a number, it works fine, but if I enter the file, then scanf no longer works, this is what I get:
k try again process returned 0 (0x0) execution time :2.578 s press any key to continue. _
means that it does not allow me to introduce a new value, why? Is there something wrong in the code? if so, how can I fix this? should i stop using scanf?
source share