how to search string and ignore cases?

May 5, 2014 at 1:07pm
hi,
i do have a string (file.txt) and use str.find for search. however, i would prefer to have a case independent search and the translation into capitals or lower letters by std::toupper or std:tolower seems to work but i guess smb knows better ways. i do not need a code - just a hint :)
cheers m
May 5, 2014 at 5:47pm
The find function will search for a specific string, but it will be case sensitive.

You could read the words from the file into a string, and make that string lowercase (a simple for-loop will accomplish this). You could then use 'find' with your new lowercase string.
May 5, 2014 at 6:57pm
smb == server message block?

Case insensitive compare FAQ
http://www.cplusplus.com/faq/sequences/strings/ci-compare/

May 7, 2014 at 10:53am
that will keep me busy,
thx a lot,
cheers m
Topic archived. No new replies allowed.