Hi im trying to read the first line of the following text file after its been read once all the way with good() method. The following is my text file named "test.dat"
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
string filename = "test.dat";
inFile.open(filename.c_str());
int sum = 0;
while(inFile.good())
{
string w, weg = "weight";
inFile >> w;
if (w == weg)
{
sum++ ; // sum is the total number of times weight appears in the data file
}
}
cout << sum << endl;
inFile.seekg(0L,ios::beg);
string were;
inFile >> were;
cout << were; // i want were to be the string "advanced"
system("pause");
return 0;
}