I am reading a file that is about 20 Mb, this will take about 10 seconds.
A few lines from this file look like below. The first value is a date value that go from lower to higher and the second value after the "Comma" is a number.
In the while statement that do read this file from top to bottom there is a if-statement that says: if( Date == "01/03/2008" )
Now is my question this Let us say that I am only interested to read the lines that are inbetween the Date 01/03/2008 - 01/06/2008.
This will meen that I will only read the nescessary lines from this 20 Mb file.
So is it possible to search for an entry and an exitpoint in this file instead of reading the file from top to bottom ?
01/01/2008,1
01/02/2008,2
01/03/2008,3
01/04/2008,4
01/05/2008,5
01/06/2008,6
01/07/2008,7
ifstream ReadFile("C:\\File1.txt");
char Comma;
std::string Date;
double Number = 0;
while( getline(ReadFile, Date, ',') )
{
ReadFile >> Number;
ReadFile.get();
if( Date == "01/03/2008" )
{
int i = 5;
}
}