/*
*@author cody
*@date 2014-08-12
*@description
*/
/*
#include <sys/mman.h>
void *mmap(void *addr,size_t len,int prot,int flag,int filedes,off_t off);
int munmap(void *addr,size_t len);
*/
#include <stdlib.h>
#include <sys/mman.h>
#include <fcntl.h> void MmapFile(){
int *p;
int fd = open("hello",O_RDWR);
if(fd < ){
perror("open hello");
exit();
} p = mmap(NULL,,PROT_WRITE,MAP_SHARED,fd,);
if(p == MAP_FAILED){
perror("mmap");
} close(fd);
p[] = 0x30313233;
munmap(p,); } int main(int argc, char const *argv[])
{
MmapFile();
return ;
}
05-28 21:55