I have two char* references and I am trying to figure out which one is less. The code I have is:
bool stringComparison::lessThan(char *s1, char* s2) {
int result = strcmp(*s1,*s2);
return result < 0;
};
the result is not producing less than 0 ever. How do I need to change the “int result” line to make this work?
thanks
strcmp is used to compare strings; *s1 and *s2 are characters. You should be calling strcmp with s1 and s2 (no stars).
EDIT:
Here is the reference for strcmp