原型:
头文件
#include <string.h>
int memcmp(const void *s1, const void *s2, size_t n);//memicmp不区分大小写
参数说明:str1和str2为指定作比较的字符串,比较两个字符串的前n个字节。
函数功能:比较字符串str1和str2在内存区域中的的前n个字节是否相同。
返回说明:当str1<str12时,返回值<0;当str11=str12时,返回值=0;当str11>str12时,返回值>0。
#include<stdio.h>
#include <string.h>
3
4 int main() {
5 char *p = “aa”;
6 char *q = “aw”;
7 printf("%d\n", memcmp(p, q, 1));
8 return 0;
9 }
结果:0