how to split a file into pages and set each page address

68 Views Asked by At

My software needs to read a file and write to a device. It should split the file to smaller pages which has a maximum size (say M bytes), and also sets page address for each cycle. How can I implement it in C?

Thanks!

Hetty

1

There are 1 best solutions below

0
On

It's not clear what are you going to do with this data but to read a file chunk by chunk you just need to use fread:

FILE *file = fopen("yourfile.dat", "rb");
size_t amount;
unsigned char buffer[PAGE_SIZE];

while ((amount = fread(buffer, 1, PAGE_SIZE, file)) > 0)
{
  ..
}