1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

compare vectors for inequality

Discussion in 'C' started by heidik, Jan 12, 2011.

  1. heidik

    heidik New Member

    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.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.
     
    Last edited: Jan 12, 2011

Share This Page