Trying to compare strings using:
!(stringvector[i]).compare(vector[j][k]) only works for some entries of
vector[j][k] -- namely ones that are a case sensitive string match.
How do I get case-insensitive matching from this functionality?
Here is a bit of code I was working on
#include <iostream> #include <vector> #include <string> using namespace std; //poor form vector<string> stringvector = {"Yo", "YO", "babbybabby"}; vector<string> vec1 = {"yo", "Yo" , "these"}; vector<string> vec2 = {"these", "checked" , "too" , "Yo", "babbybabby"}; vector<vector<string>> vvs = {vec1, vec2}; for (int v = 0; v < vvs.size(); v++) //first index of vector { for(int s = 0; s < vvs[v].size(); s++) //second index of vector { for(int w = 0; w < stringvector.size(); w++) { if (stringvector[w] == vvs[v][s]) {cout << "******FOUND******";} } } } This doesn't print out FOUND for the case-insensitive matches.
Stringvector[w] == vvs[v][s] does not make case-insensitive comparison, is there a way to add this functionality easily?
--Prof D
vectorandstringvector.vec2, the"Yo,"should be"Yo",instead?vectoris very confusing - particularly when you obviously have ausing namespace std;in effect. (Don't do that.)for (const auto& vec : vec_vec) for (const auto& str : vec) for (const auto& target : stringvector) if (target == str) { ... }- with some newlines obviously!