You're storing your new updated string in word
, but you should be updating i
Change this
for(auto &i : words) {
word = i;
for(auto &j: word) // word is updated, but your vector is not
j = toupper(j);
}
... to this:
for (auto &i : words) // for every string i in words vector
for (auto &j : i) // update your i, not word
j = toupper(j);