#include #include #include #include #include #include #

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

#include #include #include #include #include #include #

Post by answerhappygod »

#include <sys/msg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <errno.h>
struct msgbuf{
long msgtype;
char text[256];
};
int main(){
int send_id_int, recv_id_int;
char *send_id = NULL;
char *recv_id = NULL;
size_t size;
printf("My id:");
getline(&send_id, &size, stdin);
send_id[size-1] ='\0';
printf("Receiver's id:");
getline(&recv_id, &size, stdin);
recv_id[size-1] ='\0';
key_t send_k = ftok(".", atoi(send_id));
key_t recv_k = ftok(".", atoi(recv_id));
int send_qid = msgget(send_k, IPC_CREAT | 0660);
int recv_qid = msgget(recv_k, IPC_CREAT | 0660);
if(send_qid == -1 || recv_qid == -1){
perror("msgget error");
exit(0);
}
if(fork () == 0){
// Child - Receiver
}else{
// Parent - Sender





}
}
I need this C programming assignment. In C language. only modifying above c code
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply