Reputation: 215
I have a couple of questions.
First, i am doing http byte range requests and then writing the received data to a file. Sometimes, i have to read a block of 1K, and then read that from the file fetched through http. Now, the problem is that the next request after the 1k request may be starting from 100 bytes and in that case i want to write in the 1K file, overwriting from 100 bytes. How can i overwrite from a specific offset in the file?
Secondly, how do i create a file with some data already in the file? For eg. i want put the data in the file from lets say 500th byte, i do not care about the first 500 bytes, could be any garbage data, but its important to have the correct file size for the code to work.
thanks
Upvotes: 1
Views: 182
Reputation: 106236
There's some reference material and sample code on ofstream's seekp
at http://www.cplusplus.com/reference/iostream/ostream/seekp/
Upvotes: 3