R
Roberto Dias
Hi all,
What to do for searching for more than one string occurrence in the
same string (this last are line of a text). I have used getline(), to
get the text lines by means of WHILE loop and find(), to searching.
When find() finds a first occurrence it scape and don't detect
possible other one in the same string.
Here is a fragment:
***************************************************************************
cout << " " << endl;
cout << "Pesquisar pelo string: " << endl;
cin >> consulta;
comp = consulta.length();
while(ArquivoOrigem.getline(LinhaLidaArray, 80))
{
linha++;
LinhaLidaString = LinhaLidaArray;
if (LinhaLidaString.find(consulta) != string::npos)
{
cout<< linha
<< " - "
<< (LinhaLidaString.find(consulta)+1)
<< " a "
<< (LinhaLidaString.find(consulta)+1)+(comp-1)
<< "." << endl;
++ocorrencias;
}
}
***********************************************************************
thanks,
Roberto Dias
What to do for searching for more than one string occurrence in the
same string (this last are line of a text). I have used getline(), to
get the text lines by means of WHILE loop and find(), to searching.
When find() finds a first occurrence it scape and don't detect
possible other one in the same string.
Here is a fragment:
***************************************************************************
cout << " " << endl;
cout << "Pesquisar pelo string: " << endl;
cin >> consulta;
comp = consulta.length();
while(ArquivoOrigem.getline(LinhaLidaArray, 80))
{
linha++;
LinhaLidaString = LinhaLidaArray;
if (LinhaLidaString.find(consulta) != string::npos)
{
cout<< linha
<< " - "
<< (LinhaLidaString.find(consulta)+1)
<< " a "
<< (LinhaLidaString.find(consulta)+1)+(comp-1)
<< "." << endl;
++ocorrencias;
}
}
***********************************************************************
thanks,
Roberto Dias