Your count function is probably wrong. Try something like this instead (Warning, uncompiled code ahead!):
int count( const std::string& str, const char* element )
{
int count = 0;
for( size_t last = -1;
( last = str.find( element, last + 1 ) ) != std::string::npos;
++count );
return count;
}
int mycount = count( data, "HTTP" );
Take a look at the
standard strings library[
^].