not exactly sure why this doesnt work.
im taking an example from a free stanford online video but ^when compiled' it doesnt give the answer i was looking for which is the letter 'a' or number '65'
Code:
#include <stdio.h>
int main()
{
unsigned short one=1;
unsigned char two;
printf("hello world %d\n",one);
one=one << 15;
printf("hello world %d\n",one);
two = *(unsigned char*)&one;//this line gives an answer that i didnt expect
++two;
printf("hello world %d\n",two);
return 0;
}
if you could help me figure out why "char two" would reset to zero on the commented line.