📄 shm_1.c
字号:
#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>#include <stdio.h>#define SHMSZ 27int main(void){ char c; int shmid; key_t key; char * shm,*s; /*create a share_memory named 5678*/ key=5678; if((shmid=shmget(key,SHMSZ,IPC_CREAT|0666))<0) exit(0); /* connecting this share_memory to this process */ if ((shm=shmat(shmid,NULL,0))==NULL) exit(0);/* writting some letters to this memory for other process */ s=shm; for(c='a';c<='z';c++) *s++=c; *s='#';/* waitting for another process change this memory */ while( *shm !='*') sleep(1); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -