main.c~
来自「linux terminal thread semophores」· C~ 代码 · 共 29 行
C~
29 行
#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include <stdio.h>#include <string.h> struct msgbuf { long mtype; /* message type, must be > 0 */ char mtext[1]; /* message data */ };int main(){ struct msgbuf m; int ID=1,msgc; key_t key; if((key = ftok("./",'a'))==-1) perror("key"); if((msgc=msgget(key,IPC_CREAT|0640))==-1) perror("msgget"); m.mtype=1; strcpy(m.mtext,"bau bau"); if(msgsnd(msgc, &m, sizeof(m.mtext), 0)==-1) perror("snd"); printf("Merje!");}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?