[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;
}

posted @ 2013-02-03 09:43  小尼人00  阅读(426)  评论(0编辑  收藏  举报