Hello,
I am working on this project where I receive a char pointer, but need to cast it to an unsigned short. Below is an example of the code, I am trying to add code to methodB. Also I am not understanding why pointer in methodA is passed as a char and than it is passed to methodB as void. Does this have something to do with how I am casting.
methodB is saying that it can accept a pointer of any type.
This is very unsafe code. char and short have different lengths. You have no guarantee that the caller has reserved at least sizeof(short) bytes when he allocated what ptr points to. (I'm assuming ptr and buf are the same thing in your example).