I'm having some problems with the memcpy function in C... I have a pointer to a chunk of data and I simply want to copy 2 bytes from it into a short...
first of all what is the declaration of getdata and why ptrdata is a char when you are using it to store a shorth?
second you can't do a simple myshort = *(unsigned short*)ptrdata (didn't test it :P)
weltall wrote:first of all what is the declaration of getdata and why ptrdata is a char when you are using it to store a shorth?
second you can't do a simple myshort = *(unsigned short*)ptrdata (didn't test it :P)
It's ok, I worked it out... I was displaying the pointer of prtData rather than the data it contained... The memcpy did work and was correct... It was other mistakes that led me to believe otherwise...