strcasecmp函数和strncasecmp函数原型
来源:互联网 发布:剑三成男无费脸型数据 编辑:程序博客网 时间:2024/05/02 17:48
函数说明 strcasecmp()用来比较参数s1和s2字符串,比较时会自动忽略大小写的差异。
返回值 若参数s1和s2字符串相同则返回0。s1长度大于s2长度则返回大于0 的值,s1 长度若小于s2 长度则返回小于0的值.
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int strcasecmp(const char *s1, const char *s2)
- {
- int c1, c2;
- do {
- c1 = tolower(*s1++);
- c2 = tolower(*s2++);
- } while(c1 == c2 && c1 != 0);
- return c1 - c2;
- }
- int main(void)
- {
- int n = 4;
- char str1[] = "Acef";
- char str2[] = "ACEFd";
- printf("strcasecmp(str1, str2) = %d/n", strcasecmp(str1, str2));
- return 0;
- }
函数说明:strncasecmp()用来比较参数s1和s2字符串前n个字符,比较时会自动忽略大小写的差异
返回值 :若参数s1和s2字符串相同则返回0 s1若大于s2则返回大于0的值 s1若小于s2则返回小于0的值
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int mystrncasecmp(const char *s1, const char *s2, int n)
- {
- int c1, c2;
- do {
- c1 = tolower(*s1++);
- c2 = tolower(*s2++);
- } while((--n > 0) && c1 == c2 && c1 != 0);
- return c1 - c2;
- }
- int main(void)
- {
- int n = 4;
- char str3[] = "ABCf";
- char str4[] = "abcd";
- printf("mystrncasecmp(str3, str4, n) = %d/n", mystrncasecmp(str3, str4, n));
- return 0;
- }
- strcasecmp函数和strncasecmp函数原型
- strcasecmp函数和strncasecmp函数原型
- strcasecmp函数和strncasecmp函数原型
- strcasecmp和strncasecmp函数
- php strcasecmp()与strncasecmp()函数
- strcasecmp 函数 与 strncasecmp函数的介绍
- strcasecmp()和strncasecmp()比较
- strcmp,strcasecmp和strncasecmp
- strcasecmp,strncasecmp函数实现——strings.h库函数
- PHP字符串函数之 strcmp strncmp strcasecmp strncasecmp strnatcmp strnatcasecmp
- strncasecmp函数
- 字符串比较--strcasecmp()和strncasecmp()
- strcasecmp函数
- strcasecmp 函数
- strcasecmp函数
- strncasecmp与strcasecmp用法
- strcmp() strcasecmp() strncasecmp() strlen()
- strncasecmp与strcasecmp用法
- Unix编程艺术
- html jsp 页面 表格保存为word,excel的一个简单办法
- mxml库引用后无法正常编译
- JET学习笔记(三)under the hood
- DAPM之七:文档《AUDIO CODEC DAPM》放出
- strcasecmp函数和strncasecmp函数原型
- C#:类及其相关
- 据说是来自chrome的代码里的一个模板
- linux 进程间通信之消息传递
- JavaScript 函数
- GetWindowRect和GetClientRect
- ARM嵌入式软硬件开发技术群
- .Net C# 解析 HTML -- Html Agility Pack
- C++学习-----------------类继承之公有继承