Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22250

Trying to store invalid hexadecimal number in int variable

$
0
0

I have a very basic doubt. I am trying to store any invalid hex number in an int variable. By invalid number i mean a number that is using alphabets that are not in A-F range. For example see this program:

#include<stdio.h>int main(){    int a;    scanf("%X",&a);    printf("%d",a);    return 0;}

When console asks for input, I entered G. It gave the output as 63. Is it just undefined behaviour or there is some logic behind this output. For most of such inputs the output is coming out as 63. Currently working on GCC.


Viewing all articles
Browse latest Browse all 22250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>