I'm having a little problem with the std::string find function. It's not working in the applied section, so I made a little test run and it's still not working. Here's the code:
The result I am getting is "NOT found", and I can't figure why, since "Miner" is clearly present in the string. It DOES find it if the search string is "Miner_Iron" however.
Also, if I set the test string to "Miner Iron" (without the underscore), then search for "Miner", is also comes up "NOT found".
Could someone explain why the string isn't being found and how to get around it please?
EDIT - Ok, I've found that if I set the test string to "AMiner_Iron", it will be found. But why does the find function ignore the first character in a string? It doesn't really make sense, and it's quite inconvenient.
The result I am getting is "NOT found", and I can't figure why,
Perhaps you need to review the documentation for std::string.find(). This function returns the location within the string where the search string is found. In this case it is returning zero because the location is the first character. Remember zero is equal to false. Also note that if the search fails the function returns std::string::npos a very large unsigned type. You should be testing against this value, not for true or false.
... I don't understand what you mean TarikNeaj: the code was posted when I made this post. Perhaps you can simply scroll up and look before you start being rude!
I was genuinely curious, that is why I asked, it wasn't meant as an insult, sorry if you took it that way. Also, when I wrote that post you had no code, so let's not throw accusations around =)