std::string manipulation help
I have 2 std::strings called buffer and Test. I want to see if Test appears in buffer i was just wondering how this could be done in c++
Straight out of the docs. Took about 15 seconds...
string::find
Searches a string in a forward direction for the first occurrence of a substring that matches a specified sequence of characters.
string::find
Searches a string in a forward direction for the first occurrence of a substring that matches a specified sequence of characters.
Right this seems to be going in the right direction but im still not their yet
while (! FILE.eof() )
{
FILE.getline (buffer,1000);
if (std::string::find(buffer,Test))
DO THIS
else
DO THAT
}
This is basically hwat im trying to get it to perform im very new to c++ and would apreciate any feed back the previouse other replys i wasnt sure how to implement
while (! FILE.eof() )
{
FILE.getline (buffer,1000);
if (std::string::find(buffer,Test))
DO THIS
else
DO THAT
}
This is basically hwat im trying to get it to perform im very new to c++ and would apreciate any feed back the previouse other replys i wasnt sure how to implement
from the top of my head
while( FILE.getline( buffer, 1000)) if( buffer.find( Test) != std::string::npos) { //do this } else { //do that }
i tryed that i currently am getting the error
error C2228: left of '.find' must have class/struct/union type
error C2228: left of '.find' must have class/struct/union type
Ok im officially hopeless i have no idea hwta im doing i should never have taken this on but now its annoying me
This is the whole function
void IRCBot::Remscans(std::string Test, std::string nick)
{
char buffer[1000];
std::ifstream File("SCANS");
while (! File.eof() )
{
File.getline (buffer,1000);
if( buffer.find( Test) != std::string::npos)
SEND_NOTICE(nick, "WORKING");
else
SEND_NOTICE(nick, "NOT WORKING");
}
}
im probebly doing somthing fundementaly stupid i usually am
This is the whole function
void IRCBot::Remscans(std::string Test, std::string nick)
{
char buffer[1000];
std::ifstream File("SCANS");
while (! File.eof() )
{
File.getline (buffer,1000);
if( buffer.find( Test) != std::string::npos)
SEND_NOTICE(nick, "WORKING");
else
SEND_NOTICE(nick, "NOT WORKING");
}
}
im probebly doing somthing fundementaly stupid i usually am
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement