What does it mean when string 1 is "less than" string 2 in C? -
this question has answer here:
- how strcmp() work? 9 answers
in documentation of strncmp(const char *s1, const char *s2, size_t n)
function of xc8 compiler, read:
the
strncmp()
function compares two, null terminated, string arguments, maximum of n characters, , returns signed integer indicate whethers1
less than, equal or greaters2
. comparison done standard collating sequence, of ascii character set.
what mean when s1
less than s2
? charcount lower, or sum of characters, or ...? function ever return 0 when stuff {'a',0x00}
, {'a',0x00,0x00}
inputted?
could please explain clear example?
it means s1
come before s2
in dictionary or directory listing sorted lexically, etc. more clear example might "aaa" less "bbb", "aab" less "abb".
Comments
Post a Comment