Playing around with C or C99, i'm trying to understand how casting, bitshifts, and Hex values work.
I have an issue with the following
char c[4];
c[0] = 0x41;
c[1] = 0x42;
c[2] = 0x43;
c[3] = 0x00;
printf("%s", c); //prints ABC
printf("%X", c); //prints 99B11760
Where does 99B11760 come from?
So similarly...
int main() {
char a = 'a'; //ascii value is 0x41 (Mistake I made, 'a' is 0x61, 'A' is 0x41)
printf("%X\n",a); //outputs "61"? (THIS IS CORRECT OUTPUT, 'a' != 0x41)
}
I keep finding solutions to how to solve a similar problems of storing Hex values into char, but what I'm having trouble understanding is why or where some stored values do not correspond to it's ASCII values. Since it's neither the ASCII hex value, dec value, or octal Value, what value is being printed when using printf("%X\n", c);