Advertisement

vcc++5 int* to char*

Started by August 06, 2000 08:07 AM
0 comments, last by elmo 24 years, 5 months ago
hello! im using this struct typedef struct objinfo_typ { int objinfo.nr; int objinfo.xpos; int objinof.ypos; int objinfo.anim; } objinfotyp myobjinfo; than i will recieve data into this struct from a server using winsock with the following code: recv(s, (char*)myobjinfo, sizeof(objinfo_typ), 0); the problem is that the resv function wants a CHAR POINTER to the buffer ((char*)myobjinfo) and that the conversion (char*)myobjinfo dont work... i am something new to type/pointer conversion and it will be great if somebody can help me thanks for all elmo
You can not cast an object. Use the address operator ''&'' and it will work...

recv(s, (char*)&myobjinfo, sizeof(objinfo_typ), 0);

Jens

This topic is closed to new replies.

Advertisement