i have tried to make a function that does the following: given two ranked lists of items (strings), it checks to make sure that each item appears somewhere in both lists. here was the function i created to do this:
void listcheck(vector<string> testvec, vector<string> testvectwo)
{
int z;
vector<int> answer;
for( int i = 0; i < testvec.size(); i++ )
{
for( int p = 0; p < testvec.size(); p++ )
{
z=testvec[i]==testvectwo[p];
z+=z;
if (z>0){
answer.push_back(z);
break;
}
}
}
for (int t=0; t< answer.size(); t++)
{
cout << answer[t] << " " << endl;
}
}
i declared tihs with void so i could use cout to check whether i get all 1's returned or 1's and 0's. so if i compare a list like (apples, bananas, grapes, pears) to (pears, grapes, bananas, apples) i should get all 1's due to complete commonality...
i have no idea why this doesn't work with defined vectors (listone, listtwo) when i call this function with the statement
listcheck(listone, listtwo);
I am not even sure if I can call on vectors in this way inside of functions. Please help me.