An interview question asked very frequently. But, i'm not clear with the explanation, which i found on different websites. Because, when i'm trying to execute this code, then it shows _AX undeclared error.
main()
{
int i;
i = abc();
printf("%d",i);
}
abc()
{
_AX = 1000;
}
people says _AX is the pseudo global variable, that's why it shows output 1000.
*Note : - It showing error _AX undeclared, but when i declared the variable, then it shows some garbage value *
This comes up frequently? It's utter nonsense. Presumably _AX is some compiler-specific notation to access the "ax" register, which is used on x86 for return values. However there's no reason to believe the value in the register should not get clobbered between the assignment and function return. This program is invoking undefined behavior. If somebody offering you a job expects you to know such invalid practices, RUN. FAST. They're not competent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With