Original Post
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++
while( FILE.getline( buffer, 1000)) if( buffer.find( Test) != std::string::npos) { //do this } else { //do that }
Quote:
Original post by Dave Hunt
That's what the std::string::c_str() method is for.
Quote:You can pass it a C-style string too. The compiler will create a std::string out of the C-style string you pass.
Original post by Squishy
that was my first port of call however when passing buffer into function SEND_NOTICE buffer must be a std::string as thats what that function requires
void IRCBot::Remscans(std::string Test, std::string nick){ std::string buffer; std::ifstream File("SCANS"); while (! File.eof() ) { File.getline (buffer,1000); if(std::string::npos != buffer.find(Test)) SEND_NOTICE(nick, "WORKING"); else SEND_NOTICE(nick, "NOT WORKING"); }}std::string s;...std::getline(some_stream, s);#include <iterator>std::string s((std::istreambuf_iterator<char>(some_stream)), std::istreambuf_iterator<char>()); //unformattedstd::string s2((std::istream_iterator<char>(some_stream)), std::istream_iterator<char>()); //formattedThis topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more