Hi Elysia
Thanks for your reply.
I research these few past days, some people saying seekg() is used too often, and its not really good
A better way is read the whole buffer and skipping the buffer, but this is really complicated, if anyone know it really works, I will move towards this direction.
In the meantime, the problem of the output file is really consistent, the problem output is generated the same each time, the spacing is about 227 line each time for some data extracted from different files
Code:
char buffer[52];for (int i=0;i<n;i++) { fid.read(buffer, sizeof(buffer)); memcpy(&x[i], &buffer[4], sizeof(x[i])); memcpy(&y[i], &buffer[20], sizeof(y[i])); // etc}
Code:
Last point
if (dataname[i] == dataname)
{
inFile.seekg(datalength[i], ios::beg);
for (int j = 0; j < datacount[i]; j++)
{
getline(inFile, line);
outFile << line << endl;
}
system("Pause"); <---------------(If add this and press enter myself, the data is accurate and no spacing..... I don't get it!!"
}
Originally Posted by
Elysia
One possibility: To move backwards in the file, for example to overwrite some data.
Another possibility: If the OS allows it, you can seek beyond the end of the file and write there to automatically create a big file without having to fill it with garbage data. Useful for preallocation.