#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
int argSiz;
void* argBuf;
std::fstream fStream;
fStream.open("E:/Fts/Proj/Test/DFVisionConsole_Proj/DFVisionConsole/solution/DFDevDefault.dfv", std::fstream::in | std::fstream::out | std::fstream::app);
fStream.read((char*)&argSiz, 4);
while(1)
{
long pos = fStream.tellg();
fStream.read((char*)&argSiz, 4);
long pos2 = fStream.tellg();
argBuf = malloc(argSiz);
fStream.read((char*)argBuf, argSiz);
long pos3 = fStream.tellg();
long mai = fStream.tellg();
}
return 0;
}
何时
fStream.read((char*)&argSiz, ETypebufSizeSize);//argSiz = 24103
long pos2 = fStream.tellg();//size2 = 130
然后
long pos3 = fStream.tellg();//pos3 = 24247
它不应该是24247,130 + 24103 = 24233.
为什么fstream读取的数量多于指定的数量?
您可以下载测试文件DFDevDefualt.dfv https://sourceforge.net/projects/genericlist/files/?source=navbar
请帮忙。