關於strcmp這個函數標准時這樣規定的:
int strcmp ( const char * str1, const char * str2 );
Compare two strings
Compares the C string str1 to the C string str2.
This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminating null-character is reached.
Parameters
-
str1
-
C string to be compared.
-
str2
- C string to be compared.
Return Value
Returns an integral value indicating the relationship between the strings:
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
在VC中strcmp("123","1234") 返回-1,而在TC中返回-52。
標准只是規定三個值:小於零,零,大於零。具體是什么值編譯器自己定的,所以編程時候判斷小於等於大於,不能判斷是否等於1或者-1
