简单有关问题。m地图: No such device
简单问题。。mmap: No such device#include stdlib.h#include sys/mman.h#include fcntl.h#include s
简单问题。。mmap: No such device
#include <stdlib.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
int main(void)
{
int *p = NULL;
int fd = ("1.txt", O_RDWR);
//printf("fd = %d\n", fd);
if(fd < 0)
{
perror("open file");
exit(1);
}
p = mmap(NULL, 6, PROT_WRITE, MAP_SHARED, fd, 0);
if(p == MAP_FAILED)
{
puts("test1");
perror("mmap");
exit(1);
}
close(fd);
p[0] = 0x30313233;
munmap(p, 6);
return 0;
}
[解决办法]int fd = ("1.txt", O_RDWR);????
[解决办法]应该是int fd = open("1.txt", O_RDWR);