关于recv , send 数据结构的问题!!!!!!!!!!!!!!!!!
struct aaa {
int len;//这个是记录pt分配的长度
char* pt;//由于pt是变长的所以我用指针
};
aaa str;
str.pt = new char[100];
strcpy(str.pt, "hello the world");
str.len = strlen(str.pt);
byte* psend = new byte[sizeof(str)+str.len];
memcpy(psend, &str, sizeof(str));
memcpy(psend+sizeof(str), str.pt, str.len);
send(sk, (char*)psend, sizeof(str)+str.len, 0);
aaa a;
int len = recv(from[i], (char*)&a, sizeof(a), 0);//这里我先接收结构体,从而获得串的长度,
len = recv(from[i], pt, a.len, 0);//通过长度把剩余的数据接收,但是pt里的内容不是"hello the world",为什么,哪里错了?