Jul 8, 2012 at 7:01pm UTC
I know you can do (string.find ("good") !=std::string::npos to do a include thing. But is there a way to do the oposite of it? An if it doesn't include command.
Jul 8, 2012 at 7:06pm UTC
"Include Thing"
I'm interpreting this as to whether a string contains a provided sequence or not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
int main()
{
std::string hello = "Hello!" ;
std::cout <<
hello <<
// print "true" if hello does not contain "Hello"
hello.find("Hello" ) == std::string::npos ? "true" : "false" <<
// print "true" if hello does contain "Hello"
hello.find("Hello" ) != std::string::npos ? "true" : "false" <<
std::endl;
}
Last edited on Jul 8, 2012 at 7:06pm UTC