在C语言中,可以使用strcmp()函数来比较两个字符串的大小。该函数会比较两个字符串的ASCII码值,并返回一个整数值来表示比较结果。具体的比较规则如下:
示例代码如下:
#include <stdio.h>
#include <string.h>
int main() {
    char str1[] = "hello";
    char str2[] = "world";
    int result = strcmp(str1, str2);
    if (result == 0) {
        printf("两个字符串相等\n");
    } else if (result < 0) {
        printf("第一个字符串小于第二个字符串\n");
    } else {
        printf("第一个字符串大于第二个字符串\n");
    }
    return 0;
}