Hi all,
I'm trying to get an octal number from console and store it in an int variable using scanf. Here is my code.
int n;
scanf("%i", &n);
printf("\nEntered number in dec = %d", n);
printf("\nEntered number in hex = %x", n);
printf("\nEntered number in oct = %o", n);
At console I enter 0238284, then all the printfs outputs 0.
But the same works for hex, ie, if i enter 0xFA31D, then it outputs the decimal, hex and octal values correctly.
Can somebody tell me why it doesn't work in the case of octal. I'm using GCC compiler on 64-bit machine.
Thanks in advance,
Subith