i cant get all lines read with this code
Dec 19, 2012 at 6:58pm UTC
Please anyone, Am having problems reading all lines of my txt file.
below is the function i wrote to read the data in the file and search thru them. but it appears to read just only the first line.. please anyone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
int stop_tag(string f_name, string u_file,string file_put)
{
ofstream f_out;
f_out.open(file_put, ios::app);
f_out<<"Location of STOP condons TAG found at Locations :" <<endl;
ifstream yourfile (f_name);
size_t search;
if (yourfile.is_open())
{
while ( yourfile.good() )
{
getline (yourfile,u_file);
for ( int p = 1; p < u_file.length(); p++)
{
search = u_file.find("TAG" );
if ( search!= string::npos)
{
cout <<search<<"," ;
f_out<<search<<"," ;
break ;
}
}
}
}f_out<<endl;
return 0;
}
Dec 19, 2012 at 9:12pm UTC
Topic archived. No new replies allowed.