[C/C++] memcmp(char*, char*, len) 函数的用法

#include <iostream>
#include <vector>
#include <cstdio>
#include <string.h>

int main() {
    char *s1 = "Hello123uio!";
    char *s2 = "Hello123uio!";
    int r;
    r = memcmp(s1, s2, strlen(s1));
    if(!r)
        printf("s1 and s2 are identical");
    else {
        if(r<0)
            printf("s1 less than s2");
        else
            printf("s1 greater than s2");
    }
    return 0;
}

原文地址:https://www.cnblogs.com/robbychan/p/3787079.html