18,356
社区成员
发帖
与我相关
我的任务
分享
typedef struct tagSendBuf
{
int BufLen;
char*Buffer;
} tSendBuf;
typedef struct tagSendClass
{
int x;
char szBuf[28];
DWORD dw;
}tSendClass;
// example
tSendBuf *pBuf = (tSendBuf *)(new char[sizeof(tSendClass) + sizeof(int)]);
pBuf->x = sizeof(tSendClass);
tSendClass sc;
sc.x = 3;
sc.dw=4;
strcpy(sc.szBuf, "HELLO");
memcpy(pBuf + sizeof(int), &sc, sizeof(sc));
send(socket, (char *)pBuf, sizeof(tSendClass) + sizeof(int), 0);