Compare elements of string vector
Hi,
I'm trying to write a program to compare two lists of names and find the missing ones.
I thought about to put them in two vectors and compare them one by one.
This is how I started out and I get and error on the second element of if() statement.
What am I doing wrong and is there a better method to do this?
Code:
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
vector<string> myvector1;
vector<string> myvector2;
myvector1.push_back("aaa");
myvector1.push_back("bbb");
myvector1.push_back("ccc");
myvector2.push_back("aaa");
myvector2.push_back("ddd");
for_each (myvector1.begin(), myvector1.end(), [](string word)
{
if(word == myvector2.at(0))
cout << word << endl;
});
return 0;
}