Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   compare vectors for inequality (http://www.go4expert.com/forums/compare-vectors-inequality-t24496/)

heidik 12Jan2011 18:06

compare vectors for inequality
 
Hello everyone

I have to compare two vectors (having struct data from two different files) for inequality. The two vectors contain struct type of elements. E-g

Code:

Struct StructVect1
{
        string word_1;
        string word_2;
        string word_3;
        string word_4;
};

Struct StructVect2
{
        string word_1;
        string word_2;
        string word_3;
        string word_4;
};

and suppose vector1 has 10 (struct type) elements in it and vector2 has 5 (struct type) elements in it.

I want to find out all those elements of vector1 the word_1 (e-g vect1[i].word_1) of which is NOT equal to word_4 of any element of the vector2 (e-g vect2[1].word_4, vect2[2].word_4, vect2[3].word_4, vect2[4].word_4).

For example
Code:

if(
vect1[0].word_1 != vect2[0].word_4
vect1[0].word_1 != vect2[1].word_4
vect1[0].word_1 != vect2[2].word_4
vect1[0].word_1 != vect2[3].word_4
)
{
        // push_back vect1[0] to vect3[0]
}

Could you please help.


All times are GMT +5.5. The time now is 17:57.