#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int main()
{
int shmId;
char* shmaddr;
key_t key;
key=ftok(".",1);
// int shmget(key_t key, size_t size, int shmflg);
shmId=shmget(key,1024*4,0);//找到内存空间
if(shmId==-1){
printf("memo get fail\n");
}
// void *shmat(int shmid, const void *shmaddr, int shmflg);
shmaddr=shmat(shmId,0,0);//内存的映射
printf("data:%s\n",shmaddr);//输出内存的内容
shmdt(shmaddr);//关闭映射
printf("quit\n");
return 0;
}