84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
char a[2] = { '1','2' }; printf("%d", strcmp(a, "12"));
结果为 1
一个没有结束符,一个有结束符,为什么没有的比有的大?
业精于勤,荒于嬉;行成于思,毁于随。
Char is generally regarded as an unsigned integer, a[2] is a random value, and there are only two situations: greater than 0 and equal to 0.
Most of the time, a[2] is greater than '
Similar to the previous question - that question, my answer was trampled by the crowd - strings are strings, and character arrays are character arrays. The strcmp function requires you to pass in a string, because only strings have
char a[] = {'1', '2', 'rrreee'}; printf("%d", strcmp(a, "12"));
, it performs an out-of-bounds access to memory. a
a
Char is generally regarded as an unsigned integer, a[2] is a random value, and there are only two situations: greater than 0 and equal to 0.
Most of the time, a[2] is greater than '
Similar to the previous question - that question, my answer was trampled by the crowd - strings are strings, and character arrays are character arrays. The strcmp function requires you to pass in a string, because only strings have
The result you get is not actually 1, but a random value. Because the strcmp function does not know the length of, it performs an out-of-bounds access to memory.
a