I created a structure:
struct buffer
{
string ProjectName ;
string ProjectID ;
}
buffer buf;
buf.ProjectID = "212";
buf.ProjectName = "MyProj";
Now, to send this structure using the sendto method, I will draw a structure and send it as shown below:
char *sendbuf = (char*)&buf;
sentbytes = sendto(sock,sendbuf,strlen(sendbuf),0,(sockaddr*)&their_addr,sizeof(their_addr));
But while I sketch my Struct ti char*, the actual data loses its values, and during debugging I see that sendbuf contains some other values.
Can someone let me know how I can send the specified structure using sendto.
source
share