Compare if two strings are the same in the C language.

In C language, the strcmp() function can be used to compare if two strings are the same. The function will return an integer value: 0 if the two strings are the same, less than 0 if the first string is smaller than the second string, and greater than 0 if the first string is larger than the second string.

Here is an example code comparing two strings if they are the same:

#include <stdio.h>
#include <string.h>

int main() {
    char str1[] = "Hello";
    char str2[] = "Hello";

    if (strcmp(str1, str2) == 0) {
        printf("两个字符串相同\n");
    } else {
        printf("两个字符串不同\n");
    }

    return 0;
}

The output result is: “the two strings are the same”.

bannerAds