Dereferencing within a buffer
- by kaykun
Let's say I had a char pointer pointing to a buffer that contained these values (in hex):
12 34 56 78 00 00 80 00
I want to modify the last two bytes to a short value of 42. So I would think I would have to do something like this:
(short)*(pointer+6)=42;
The compiler doesn't complain but it does not do what I'm expecting it to do. Can someone tell me the correct way to assign the value?