Since tolower only works for individual characters, how would I use tolower for a string vector? I know I would have to go through each individual character of each item, however I am unsure how to access the individual characters within each item.
eg:-
string vector[Apple, Banana].
vector[0] is Apple but I want the character not the whole string. Thanks in advance!
std::transformcan help you here to applytolowerto each character in each string inside in your vector:Demo
As @AlanBirtles suggested you could apply
std::transformfor the outer loop too. Then it becomes like this:Demo