#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <utility>
using namespace std;
int main()
{
vector<char> vectorObject, vectorObject2;
pair<vector<char>::iterator, vector<char>::iterator> p;
char str1[] = "O, T, T, T";
char str2[] = "O, T, F, F, N";
int i;
for(i = 0; i <strlen(str1); i++)
vectorObject.push_back(str1[ i ]);
for(i = 0; i <strlen(str2); i++)
vectorObject2.push_back(str2[ i ]);
cout << "Contents of vectorObject: ";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[ i ];
cout << endl;
cout << "Contents of vectorObject2: ";
for(i = 0; i <vectorObject2.size(); i++)
cout << vectorObject2[ i ];
cout << endl;
p = mismatch(vectorObject.begin(), vectorObject.end(), vectorObject2.begin()); // find the first mismatch
if(p.first != vectorObject.end()) { // mismatch found
cout << "The character " << *p.first;
cout << " in vectorObject mismatches the character ";
cout << *p.second << " in vectorObject2.";
}
return 0;
}
|