能否发送结构体数组?
typedef struct aaa
{
int a;
char b[10];
}AAA;
// 发送端
AAA sutArray[5];
memset(sutArray, 0, sizeof(sutArray));
for (int i=0; i<5; i++)
{
AAA stru;
stru.a = i;
strcpy(stru.b, "LALALA");
memcpy(sutArray+i, stru, sizeof(stru));
}
send(sock, (char *)sutArray, sizeof(sutArray));
// 接收端
AAA othArray[5];
memset(othArray, 0, sizeof(othArray));
recv(sock, (char *)othArray, sizeof(othArray));
出现问题: othArray前三个没有数据, 后两个有. 是什么原因?