Why not just compare numbers, but use string handlers

dengmian1314 注册会员
2023-01-25 14:03

This is the syntax(the ass of the turtles), for example, why the main function is written. Just remember, hope to adopt

cupidcool 注册会员
2023-01-25 14:03

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

dongwei1529 注册会员
2023-01-25 14:03

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.

dwayne2010 注册会员
2023-01-25 14:03

About the Author

Question Info

Publish Time
2023-01-25 14:03
Update Time
2023-01-25 14:03

Related Question

“NameError: name 'y' is not defined”是什么意思?


当上传字段到github与API时,获得not json可序列化

出现TypeError: 'NoneType' object is not iterable该怎么办

cubeIDE报错program does not exist

Could not determine the dependencies of task



ADO.NET query returning nothing even if the item available

在使用C free时报错gcc.exe: cannot specify -o with -c or -S and multiple compilations