I have as input a char pointer: char* source.
Assume that source contains the string "helloworld".
Then we do this:
I understand that source is a pointer to a character, so source is essentially just a 32-bit integer of some memory address in the system i.e. 0x001b5b15, and de-referencing it will give me "helloworld". But I'm not sure what happens when I cast it to unsigned short. I believe that it will truncate the first 2 bytes and return only the last 2 bytes: 0x00005b15 and de-referencing this memory address will return some unknown value. Is my understanding correct?Code:unsigned short a = *((unsigned short*)source);