Just wondered if I have missed something and if the following code could be more elegant?
I'm hunting through a network trace. Each row is in s_current_row. If I find one of the searchstrings (could be multiple occurrences of each searchstring) stored in array searchstring[x] then I replace it with some values including the integer that is the index of the searchstring.
Any thoughts for still a newbie very welcome, Nigel
Code:
// loop through search strings
int result;
for (int x = 1; x <= countdef; x++)
{
while ((result = s_current_row.find(searchstring[x], 0)) != -1)
{
string temp = "***";
stringstream out;
out << x;
temp += out.str();
temp += "|";
temp += database[x];
temp += "|";
temp += field[x];
temp += "***";
s_current_row.replace( result, searchstring[x].size(), temp );
}
}
Last edited by nigelhoath; April 18th, 2009 at 10:17 PM.
speedo: I haven't checked out boost yet and as this stuff is compiled on lots of different environs I want to stay as clean (traditional - standard) as I can.
Bookmarks