Here is my scenario i have a file 2000 bytes long. I want to read bytes 500 - 1500 so that i have the middle 1000 bytes stored. I then want to disect the 1000 bytes into 20 bte chunks and preform calculations on ever 20 byte sectiong until the end of the 1000 bytes. I have the following code and i just want to check that what i have is a sensible way of doing things and if it wil actually work!
char *buffer1 = new char[ROOT_DIR_SIZE][Size]; //ROOT_DIR_SIZE = to 1000, Size = to 20, these have been intialised earlier
f.seekg (START_OF_ROOT,std::ios::beg) ; // positions he file at the 500th byte, 'f' is the file stream
for(i=0;i<ROOT_DIR_SIZE;++i)
{
f.read(buffer1, ROOT_DIR_SIZE*sizeof(char)); // read until the 1000 byte buffer is full
for(j=0;j<Size;++j)
{
f.read(buffer1, Size*sizeof(char)); //read until the 20 byte buffer is full
//any calculations on the 20 bytes would have to occur in here???
}
}
My question is will this keep reading the 20 byte chunks until the end of the 1000 byte buffer is reached?
thanks