I have a char pointer that holds the following information:
char* data = "22";
I want to copy it from the char into a short variable. I have the following code:
short BinarySerializer::getMessageTypeID(char* data)
{
short* messageTypeID;
memcpy( messageTypeID, data, sizeof( messageTypeID ) );
return *messageTypeID;
}
I don't know why, but when I'm printing it I get: 12850.
This is how I'm printing it:
short temp = msg->messageTypeID;
cout << "Message ID is: " << temp << endl;
Thanks in advance