|
Jul17Written by:Martin 17.07.2009 16:59 
No funny things this time, but something for everybody who knows C++. Somebody (not me) changed this line to This is not made up, but a real code change, a little bit simplified. The intention is to find ‘x' everywhere in the string, not only at the first position. str is a std::string. Why does this change not work as expected? Tags: 4 comment(s) so far...
Re: Quiz I would check for != -1 to figure if the string was found, but I can't tell why >= 0 wouldn't work. By tom.wellige on
18.07.2009 17:36
|
Re: Quiz You're right. Your check would work. But I'll wait a little bit to see if someone else finds the solution before I post the answer :-) By Martin on
20.07.2009 07:53
|
Re: Quiz Ok, probably nobody reads this anyway, so I'll no longer wait :-) std::basic_string::find() returns a size_type which is an unsigned int. Therefore every possible value you might get from find() is greater or equal zero. The if statement will never be false, even in the case when 'x' is not found. By Martin on
21.07.2009 08:54
|
Re: Quiz I read it, but had no clue!! ;) By morten.rokosz on
22.07.2009 20:05
|
|
|