kathyayini
Programmer
I have structure called
struct senddata
{
int istatus;
char cstrmsg[50];
}sd;
char cSendBuf[100]; //char arr
I wants to copy the data of structure in to cSendBuf. i tried to copy but not successful. code is as follows
memset(&sd, '\0', sizeof(sd));
memset(cSendBuf, '\0', sizeof(cSendBuf));
strcpy(sd.cstrmsg,"Failure###"
sd.istatus = 3;
memcpy(cSendBuf,&sd,sizeof(sd));
printf("msg is :%s\n",cSendBuf);
send(sock_id,cSendBuf,10,MSG_NOSIGNAL); //socketing
what could be the problem.
struct senddata
{
int istatus;
char cstrmsg[50];
}sd;
char cSendBuf[100]; //char arr
I wants to copy the data of structure in to cSendBuf. i tried to copy but not successful. code is as follows
memset(&sd, '\0', sizeof(sd));
memset(cSendBuf, '\0', sizeof(cSendBuf));
strcpy(sd.cstrmsg,"Failure###"
sd.istatus = 3;
memcpy(cSendBuf,&sd,sizeof(sd));
printf("msg is :%s\n",cSendBuf);
send(sock_id,cSendBuf,10,MSG_NOSIGNAL); //socketing
what could be the problem.