#include <iostream>
#include <fstream>
usingnamespace std;
int main() {
string Line;
ifstream Source ("myname.txt");
if ( Source.is_open() ) {
while ( Source.good() ) {
Source.seekg (11, ios::beg);
getline(Source,Line);
cout << Line << endl;
}
}
Source.close();
system("pause");
return 0;
}
The propose of this program is to read and text file, and hopefully only print the names to console. Unfortunately seekg is causing the console to loop "Bill" and without seekg it will read the entire text file just fine.
my name is bill
my name is earl
etc...
it loops Bill.
This is not a homework problem, I just remeber seeing someone do this before and thought it would be a good starting point. I have checked several sites, and sadly none of my friends know C++ either, any help would be appreciated.