Search code examples
c++streamseekg

C++ seekg to ignore a part of a file?


I have a very simple question in C++. What is the equivalent of

x = new char[length];
mystream.read(x, length*sizeof(char));
delete[] x;

with seekg to ignore a part of size length of a binary file ?

Thank you very much !


Solution

  • You don't need seekg, just use istream::ignore.


    If you insist on using seekg, the way to go is seekg(length, std::ios::cur).