Inputting a string to
scanf("%d",&var) returns 0.
There is a similar question here, but the explanation of what happens internally is not provided. What is provided is a way to handle the situation.
How exactly does GCC handle strings passed to scanf("%d",&var) and why is the return value 0 in this case?