Hey.
Suppose I want to scanf an int - here it doesn't work if I just do:
Why is it?Code:int in;
scanf("%i", &in);
What's the difference between that and:
Thanks in advance.Code:float f;
scanf("%f", &f);
Printable View
Hey.
Suppose I want to scanf an int - here it doesn't work if I just do:
Why is it?Code:int in;
scanf("%i", &in);
What's the difference between that and:
Thanks in advance.Code:float f;
scanf("%f", &f);
I'm not sure what you're getting at. Both of those seems to "work".
However, if you mean to only allow decimal input for the integer then it's better to use %d instead of %i since %i accepts inputs like 010 as octal (hence decimal 8, not 10), which is probably not what the user intended. Although %i is sometimes useful, especially for hex input in the for 0xab.
@John - we are now discussing this issue at the other thread.
Thank you!!!