Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c strcmp

// strCmp implementation
// string1 < string2 => return a negative integer
// string1 > string2 => return a positive integer
// string1 = string2 => return 0
int strCmp(const char* s1, const char* s2) {
    while(*s1 && (*s1 == *s2)) {
        s1++;
        s2++;
    }
    return *s1 - *s2;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #strcmp
ADD COMMENT
Topic
Name
9+5 =