链接: cstring之memcmp.
(http://www.cplusplus.com/reference/cstring/memcmp/)
示例给出了一种类似strcmp的用法,可以用它来比较字符串……
‘DWgaOtP12df0’ is greater than ‘DWGAOTP12DF0’.
DWgAOtp12Df0 is greater than DWGAOTP12DF0 because the first non-matching character in both words are ‘g’ and ‘G’ respectively, and ‘g’ (103) evaluates as greater than ‘G’ (71).
简单写一下测测:
示例代码 #include <stdio.h>#include <string.h>int main() { int a[10]={1,2,3,4}; int A[10]={1,2,3,4}; int b[10]={5,6,7,8}; printf("%dn",memcmp(a,b,sizeof(a))); printf("%dn",memcmp(a,A,sizeof(a))); printf("%dn",memcmp(b,a,sizeof(a))); return 0;} 运行结果tbc.