Question about reading files

I have a file with N blocks of data. There is a space of two empty rows between them. I would like to make a script in c++ that read only the last block in order to make more calculations and graphics with those data. How can I do that? Thanks.
Last edited on
Open file.
Read first block into memory
Read next block, overwriting the first block in memory.
Read next block, overwriting the first block in memory.
...

Eventually, there will be no next block and the data in memory will be from the last block.
Yes, that is a possibility, but maybe I have a lot of blocks, thousands of them. There is something more efficient and elegant, like going to the end of the file and then go back the size of one block?
Are the blocks of fixed size? Exactly the same amount of data in every block? Exact same number of characters, always?
Yes. There are represented the position of N particle in each block. So there are a lot of blocks (unknown number), but all of them are formed by N rows and 2 column (position of particles in 2-D).
But is the block always exactly the same number of bytes? Is every row the same size? Is N a fixed value that can be establish at run time?
Last edited on
N can be establish at run time, the blocks are composed of double precision real numbers between 0 and 1200 and the rows could have different number of columns because numbers can be different.
you can use the file size to find the correct position to jump to in a fixed chunk file. Is this what you need to see?
Registered users can post here. Sign in or register to post.