Original Post
Hi. I am making my own string class and I do not want to use strcmp in my compare function. I understand that the function is suppose to return 0 if the strings letters are equal but the part I don't understand is how to check if the letters are alphabetically less or greater than if the strings aren't equal. The compare function is suppose to return -1 if the letter is alphabetically less than the other strings letter and a 1 if greater than the other strings letter. I am unsure how to compare the letters to see if they are alphabetically less or greater. Here is my code so far: int MyString::Compare(const MyString & aMyString) { int addUpStringElements = 0; if (_length == aMyString._length) { //iterate through the strings comparing each element for (int i = 0; i < _length; i++) { //if the elements are equal then add 1 if (_string == aMyString._string) { addUpStringElements++; } //if addupstringelements is the size of length then the strings are equal if (addUpStringElements == _length) { return 0; } } } I have the equal part done. I just need to know how to check alphabetical. Thanks.