I was assigned by my teacher to write my own strcmp()
function in C. I did create my own version of said function, and I was hoping to get some feedback.
strcmp
compares alphabetically: so "aaa" < "b"
even though "b" is shorter.
Because of this, you can skip the length check and just do the letter by letter comparison. If you get to a NULL character while both strings are equal so far, then the shorter one is the lesser one.
Also: make StringsAreEqual == 0
, not 1
for compatibility with standard sorting functions.