Hai, I'm a C++ beginner with self learning.I have a function that return a vector string

eg: vector <string> result :"PA1070","PA1088","PA1091","Pa1070","PA1044".....

How do I compare the vector string element in a proper way?

I tried to compare

(if result[0] < result[3] )
cout << "True";
else
cout << "False";

it should return False , because PA1070 is not lower than PA1070 ...But it returns True, why ? thanks

Sorry , my bad. They are the same "PA1070", wrong written.

How to edit the first post ? I cannot find the Edit button

I agree that the overloaded < for STL strings should return false if lhs is equal to or greater than rhs. So why it isn't isn't clear by the code you posted. So, print out the values of result[0] and result[3] and see if they are what you expect them to be, or use your debugger to try to follow along and look at the values that way.

Thanks for the tips , I have found the culprit through debugger . Problem solved.

This question has already been answered. Start a new discussion instead.