I have following code (simplified):
std::string file = "TestName.raw.craw";
int index1 = file.find_last_of(".craw");
int index2 = file.find_last_of(".raw");
Why is index1 == index2 after this? (both are 16)
Is the . skipped for some reason, or something? I checked at http://msdn.microsoft.com/en-us/library/h21280bw.aspx and the point was not in the list of characters that need to be escaped, so what is happening here?
find_last_of() finds the last occurrence of any character that appears in its argument. Here, it's the final w in both cases.
You should use rfind() to find the last occurrence of a substring in any string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With