Function File: rval = cstrcmp (s1, s2)

Compare strings s1 and s2 like the C function.

Aside the difference to the return values, this function API is exactly the same as Octave’s strcmp and will accept cell arrays as well.

rval indicates the relationship between the strings:

  • A value of 0 indicates that both strings are equal;
  • A value of +1 indicates that the first character that does not match has a greater value in s1 than in s2.
  • A value of -1 indicates that the first character that does not match has a match has a smaller value in s1 than in s2.
cstrcmp ("marry", "marry")
  ⇒  0
cstrcmp ("marry", "marri")
  ⇒  1
cstrcmp ("marri", "marry")
  ⇒ -1

Package: strings