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

But PA1070 is not the same as Pa1070

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.

Please post the solution. This may help someone in the future.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.