比较字符,应该怎么改

img

img

img

题目都叫你独立实现strcmp函数了,你还在那用

#include <stdio.h>
int main() {
    char a[10], b[10];
    gets(a);
    gets(b);
    int i, res = 0;
    for(i = 0; a[i] != '\0' && b[i] != '\0'; i++) {
        if(a[i] > b[i]) {
            res = 1;
        } else if(a[i] < b[i]) {
            res = -1;
        }
    }
    printf("%d", res);
    return 0;
}