I have to compare two strings which are stored in a vector. Comparison works fine in Windows which uses mingw-g++ compiler(version 4.4.1).
But when I try to do the same in Ubuntu which is running g++ version 4.7.2 I am getting weird problems. I listed them below:
When I try to print the elements individually, they are giving correct output and both strings are same.
But when I try to compare them using == operator or strcmp() it is saying that they are not equal even though they are same.
When I try to print the elements which are compared above some string is replacing first string's value. The code is given below. Ideally the if loop shouldn't be executed, but it is still executing and printing some garbage value instead of v1[i].
vector<string> v1 = r1->GetSchema().GetAttrTypes(); vector<string> v2 = r2->GetSchema().GetAttrTypes(); for(i=0; i<v2.size();i++) if(v1[i] != v2[i]) cout << v1[i] << " " << v2[i] << " awdsd" << endl;
I don't know what to search for these kind of errors. I am taking strings from same file and storing in vectors in both Windows and Ubuntu.
EDIT: I am attaching part of the code here. The function right side returns vector of strings. I can't paste above classe's code as it is very big code.