fork download
  1. #include<stdio.h>
  2. #include<sys/ipc.h>
  3. #include<sys/msg.h>
  4. struct msg_buffer {
  5. long msg_type;
  6. char msg[100];
  7. } message;
  8. main() {
  9. key_t my_key;
  10. int msg_id;
  11. my_key = ftok("progfile", 65);
  12. msg_id = msgget(my_key, 0666 | IPC_CREAT);
  13. message.msg_type = 1;
  14. printf("Write Message : ");
  15. fgets(message.msg, 100, stdin);
  16. msgsnd(msg_id, &message, sizeof(message), 0);
  17. printf("Sent message is : %s \n", message.msg);
  18. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Write Message : Sent message is :