/* * Outro exemplo de arquivo mapeado em memória. */ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> #include <unistd.h> #include <string.h> int main() { int fd; char* map, *str = "Outra string \n"; fd = open("teste.txt", O_RDWR); map = mmap (NULL, 100, PROT_WRITE, MAP_SHARED, fd, 0); strcpy(map, str); munmap(map, 100); close(fd); return 0; }