int number=0, subtranslines=50;
string term[]={"Jordan"};
//string term="Jordan";
string voltage= "69";
string line;
size_t found;
while (! data_file.eof() && getline(data_file,line).good() )
{
//cout<<line<<'\n';
for (int i=0; i <=subtranslines; i++){
if( (found=line.find ("term[i]",0)) !=string::npos && (found=line.find (voltage,0)) !=string::npos)
{
number++;
cout<<line<<'\n';
out_file<<line<<endl;
}}}
//To find the number of outages and subtract the header
cout<<"number = "<<number<<'\n';
The code works when I do not try to pass term and just use term. What I am trying to do is read in a file, search for a word, if the row contains that word write it to a file and keep searching until it does not find it and then search for the next word, find, write it and so on.
For some reason it will not work when I try and use an array.
Another questions...
On the line
if( (found=line.find ("term[i]",0)) !=string::npos && (found=line.find (voltage,0)) !=string::npos)
What does the ,0 do after the two terms??
Thank YOU!