test11_3.txt
来自「Linux下的C语言编程」· 文本 代码 · 共 34 行
TXT
34 行
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#define BUF_SIZE 1024
#define MYKEY 24
int main(void)
{
int shmid;
char *shmptr;
if(shmid=shmget(MYKEY, BUF_SIZE, IPC_CREAT)==-1)
{
printf("shmget error! \n");
exit(1);
}
if((shmptr=shmat(shmid,0,0))==( void*)-1)
{
fprintf(stderr,"shmat error!\n");
exit(1);
}
while(1)
{
printf("string: %s \n", shmptr);
sleep(3000);
}
exit(0);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?