69,371
社区成员
发帖
与我相关
我的任务
分享
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<stdio.h>
#include<stdlib.h>
#define BUF_SIZE 1024
#define MYKEY 24
int main(){
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){
printf("shmat error!\n");
exit(1);
}
while(1){
printf("strinig in the share memory is: %s\n", shmptr);
sleep(10);
}
return 0;
}