C语言 - 比较部分字符串函数的使用

来源:互联网 发布:unity3d动画制作教程 编辑:程序博客网 时间:2024/05/17 21:45
/**********************************************************文件名称: 比较部分字符串函数的使用基本操作: memcmp()声明于头文件string.h使用方法:原型int memcmp(str1, str2, count);类似于  strncmp()函数完成日期:2015 - 12 - 20编程平台:Visual Studio 2015注意事项:**********************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){int returnValue = 0;char *str1 = "One World";char *str2 = "One Dream";// str1 > str2: 返回值 > 0;// str1 = str2: 返回值 = 0;// str1 < str2: 返回值 < 0;returnValue = memcmp(str1, str2, 5);printf("\n\t函数的返回值为:%d\n", returnValue);system("pause");return 0;}

 

运行结果:


0 0