📜  c strcmp - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:42.480000             🧑  作者: Mango

代码示例2
// 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;
}