How can I make user enter custom message for the msgbuf.mtext? Whenever I try to change it manually I am getting following error:
struct msgbuf msg
expression must be a modifiable lvalue
What am I doing wrong?
struct msgbuf {
long mtype;
char mtext[80];
};
int main() {
int qid, opt;
int mode = 0;
int msgkey = 1234;
qid = msgget(msgkey, IPC_CREAT | 0666);
struct msgbuf msg;
msg.mtext = "hello";
msgsnd(qid, (void *) &msg, sizeof(msg.mtext), 0);
printf("sent: %s\n", msg.mtext);
return 0;
}