如何用n个字符移动istream的指针?

hyp*_*not 5 c++ binaryfiles

我想跳过两个istream getlines之间的二进制文件中的几个字符.最好的方法是什么?

Shell我刚刚用istream :: read读入了一个虚拟变量?

或shell我使用n = istream :: tellg和istream :: seekg = n + 1000?

Ker*_* SB 20

您可以使用std::ios::curposition参数简单地相对于当前位置移动流位置:

std::ifstream f("myfile.txt");   // current position 0
f.seekg(200, std::ios::cur);     // relative seek
Run Code Online (Sandbox Code Playgroud)

也允许负值.见例如这里.