#include<unistd.h> #include<sys/mman.h> #include<stdio.h> #include<stdlib.h> main() { int *p=mmap(NULL,//由系统指定开始位置 getpagesize(), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_SHARED, 0, 0); *p=20; *(p+1)=30; *(p+2)=40; printf("%d\n",p[2]); munmap(p,4096);//释放内存 }