For example:
int number = scanf("%d", &number);
9
The return value of scanf
is the number of items assigned. So, when successful, scanf("%d", &number)
returns 1. Then int number = scanf("%d", &number);
says to initialize number
to 1. That is not what you want.
int number = scanf("%d", &number);
also tells scanf
to store the result of converting a decimal numeral from input in number
. Which happens first, storing the conversion result or storing the return value? Interpreting this gets into a mess with the C standard. It is not worth figuring that out, because you just should not write code like this.
9