//header files #include"msgbuf.h" int main() { int msqid; key_t key; int msgflg = 0666; message_buf *rbuf; rbuf=malloc(sizeof(*rbuf)); rbuf->m=malloc(sizeof(M1)); key = ftok("/home/user",12); if ((msqid = msgget(key, msgflg)) ==-1) { perror("msgget"); exit(1); } printf("\n\n%d\n",msqid); //working fine till here. /* Receive an answer of message type 1. */ if (msgrcv(msqid, &rbuf, sizeof(rbuf->m), 1, 0) < 0) { perror("msgrcv"); exit(1); } /* Print the answer. */ printf("Received message text= %s\n", rbuf->m->cp); return 0; }
typedef struct msgclient { int msglen; int msgtype; char *cp; }M1; typedef struct msgbuf1 { long mtype; M1 *m; } message_buf;
sizeof(rbuf->m)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)