Hey guys,
Curiously...I just read that a string member function (for example, find() in my case) returns a -1 if it doesnt find the specified target. If this is true (which I can only assume it is b/c I read it in a book ...OH...and tested it myself hehe) why does the following work?
It didnt find the target...yet it printed "found it" to the screen...it just seems a little backwards to me. Any ideas why it was implemented this way? The only logic I can see is so when you set up test conditions you can logically think it out asCode:if (someString.find(target)) //assuming target is NOT in the string cout << "found it!" else cout << "didnt find it...";...Any replies would be cool...thanks a lot. -ChapCode:if (!(str.find(target)) //if it doesnt find target