/* a sample program that maps a file to address then
prints the content of the address, and then unmaps the address */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

int main() {
    int fildes;
    char *address;
    int len = 10;
    
    fildes = open("mmap.c",O_RDONLY);
    address = mmap(0, len, PROT_READ, MAP_PRIVATE, fildes, 0);
    printf(" %s \n",address);
    munmap(address,len); /* remove the mappings for page */
    close(fildes);   
}
