I have large text files that I need to embed a code (time) into, part of the way through the file. I do this by iterating through an ifstream to the point the code needs to be inserted into, and then proceed to iterate through the rest of the file, continuously copying the data into a new ofstream file.
These files are large, and almost all of this simple copy and paste operation occurs after the code insertion. This takes a while to execute. I was wondering if there was a way to optimize copying the rest of the file in bulk (rather than word-by-word iteration for the rest of the file). This is the relevant code segment:
while (!in.eof())
{
in >> value;
if ((counter > 392) && (counter < 399) && (timePosition < 6))
{
rounded = floorf(value * 1000) / 1000;
value = rounded + (time[timePosition] * .00001);
timePosition++;
}
out << value << " ";
counter++;
}