char* ReadNumericFormat = "%i";
int Read(void)
{
int Storage;
__asm
{
LEA EAX, [Storage]
PUSH EAX
PUSH DWORD PTR [ReadNumericFormat]
CALL DWORD PTR [scanf]
ADD ESP, 8
MOV EAX, DWORD PTR [Storage]
}
}
when the user enters “023919” the procedure returns 19.
this is a feature or darkness is a standard?
Actually that’s because you’ve entered an octal number.
In C, numbers starting with 0 will be interpreted as octal (base-8) literals. Hence, in your input
scanffind a leading zero without anxfollowing, so assumes it’s an octal number. Then it consumes2and3, until9which is not a valid octal digit and stop. Soscanfnow haswhich is
So the procedure returns 19.
Use the format
%dinstead of%ito prevent this.