I want to read a file "A" of x size. Then I want to implement a buffer of size 2MB and fill the buffer completely i.e 2MB by reading from the file "A." Then i want to read 4kb from this buffer and send 4kb as an input to some function say func_A(). This func_A() should print the data which is given to it along with size of the data for each print.
After the buffer is completely read and sent in 4k chunks, the buffer should be again filled up with new data reading from the file A. If there is any left over data after completely sending 4kb chunks from the buffer, say 2kb is left, this left over 2kb should be added to the starting index of the buffer and then followed by new data to be added from the file "A". and continue with 4kb chunks.
While we reach EOF, if there is not enough data to fill in the 2MB buffer completely, and not even 4kb, then it can also be read and sent as the final chunk.
Can this be done in C/C++?
Aucun commentaire:
Enregistrer un commentaire