I would like to skip a few characters in a binary file between two istream getlines. What is the best way to do it?
Shell I just read into a dummy variable with istream::read?
Or shell I use n = istream::tellg and istream::seekg = n + 1000?
You can simply move a stream position relative to the current position by using the std::ios::cur
position argument:
std::ifstream f("myfile.txt"); // current position 0
f.seekg(200, std::ios::cur); // relative seek
Negative values are also permitted. See e.g. here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With