This is the syntax(the ass of the turtles), for example, why the main function is written. Just remember, hope to adopt
0 Answer
This is the syntax(the ass of the turtles), for example, why the main function is written. Just remember, hope to adopt
Because only numeric variables can be compared by ==, and strings cannot be compared by ==, which depends on the storage structure of the data type. That's how you do it. Hope to adopt
The following figure uses the == sign to compare only the size of the first address of the string, not subsequent characters;
Instead of using strcmp compare, which is int strcmp(const char *str1, const char *str2), the argument is to compare the string that str1 points to with the string that str2 points to. When comparing, The function moves to the next character, and when its result is greater than 0, it means that str1 is less than str2 if the return value is less than 0; If the return value is greater than 0, str1 is greater than str2; If the return value is 0, str1 is equal to str2.
Of course, it's not impossible to use == comparison for string comparisons, but it's a hassle to write your own loop to compare two strings in sequence to see if the characters in the same position are equal.
这家伙很懒,什么都没留下...