Hey all. I am having a slight problem with strcmp. I am comparing a two last names and two first names and the problem occurs when two of the same last names are entered. How can I fix this problem?
Any suggestions would be great!! NOTE: I am not asking for code just a push in the right direction.
Code:bool LessThanByName( const Passenger & passenger ) const { char last0[MAX_LENGTH + 1]; char last1[MAX_LENGTH + 1]; char first0[MAX_LENGTH + 1]; char first1[MAX_LENGTH + 1]; for(int i = 0; i < last[i]; i++) { last0[i] = toupper(last[i]); } for(int i = 0; i < passenger.last[i]; i++) { last1[i] = toupper(passenger.last[i]); } for(int i = 0; i < first[i]; i++) { first0[i] = toupper(first[i]); } for(int i = 0; i < passenger.first[i]; i++) { first1[i] = toupper(passenger.first[i]); } if(strcmp(last0, last1) == 0) return (strcmp(first0, first1) < 0); return (strcmp(last0, last1) < 0); }