Using memory mapping in C for reading binary
- by user1320912
I am trying to read data from a binary file and process it.It is a very large file so I thought I would use memory mapping. I am trying to use memory mapping so I can read the file byte by byte. I am getting a few compiler errors while doing this. I am doing this on a linux platform
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
int fd;
char *data;
fd = open("data.bin", O_RDONLY);
pagesize = 4000;
data = mmap((caddr_t)0, pagesize, PROT_READ, MAP_SHARED, fd,
pagesize);
The errors i get are : caddr not initialized, R_RDONLY not initialized, mmap has too few arguments.
Could someone help me out ?