When using msgsnd the structure mentioned in man page is
struct mymsg {
long mtype; /* message type */
char mtext[1]; /* body of message */
};
But if you use it like
func(char *array, int sizeofarray)
{
struct mymsg {
long mtype; /* message type */
char *ptr; /* body of message */
};
msgq.mtype = 1;
msgq.ptr = array;
msgsnd(msqid, &msgq, sizeofarray, 0);
}
Assign ptr to some local array[200] (array could be got as a parameter in function), the message received on the other side is junk. Why is this?