+ 2

C pointer and Typecasting (need help)

Hi, i got this code from my CS coding professor. Can somebody explain it to me please. #include <stdio.h> int main() { unsigned int i = 3224374275u; printf("%d\n", *(unsigned char*)&i); // 3 printf("%d\n", *((unsigned char*)&i+1)); // 12 printf("%d\n", *((unsigned char*)&i+2)); // 48 printf("%d\n", *((unsigned char*)&i+3)); // 192 printf("%d\n", *(unsigned short*)&i); // 3075 printf("%d\n", *((unsigned short*)&i+1)); // 49200 }

3rd May 2019, 5:40 PM
Maxim Schiffmann
Maxim Schiffmann - avatar
4 Respuestas
+ 4
Thank you so much, both of you. I see, still a lot to learn :)
3rd May 2019, 7:33 PM
Maxim Schiffmann
Maxim Schiffmann - avatar