strncmp函数详解
strncmp
函数名: strncmp
功 能: 串比较
用 法: int strncmp(char *str1, char *str2, int maxlen); 说明:比较字符串str1和str2的大小,如果str1小于str2,返回值就<0,反之如果str1大于str2,返回值就>0,如果str1等于str2,返回值就=0,maxlen指的是str1与str2的比较的字符数。此函数功能即比较字符串str1和str2的前maxlen个字符。
程序例:
#include <string.h>
#include <stdio.h>
int main(void)
{ char *buf1 = "aaabbb", *buf2 = "bbbccc", *buf3 = "ccc"; int ptr; ptr = strncmp(buf2,buf1,3); if (ptr > 0) printf("buffer 2 is greater than buffer 1\n"); else if(ptr<0) printf("buffer 2 is less than buffer 1\n"); ptr = strncmp(buf2,buf3,3); if (ptr > 0) printf("buffer 2 is greater than buffer 3\n"); else if(ptr<0) printf("buffer 2 is less than buffer 3\n"); return(0); } PHP中:
函数名: strncmp ()
功 能:比较字符串的前N个字符
用 法: int strncmp(string str1, char str2, int len);
说明:比较字符串str1和str2的大小,如果str1小于str2,返回值就<0,反之如果str1大于str2,返回值就>0,如果str1等于str2,返回值就=0,len指的是str1与str2的比较的字符数。此函数功能即比较字符串str1和str2的前len个字符。
提示:该函数区分大小写。
Linux C编程--string.h函数解析_计算机软件及应用_IT/计算机_专业资料。精品... ptr = strncmp(buf2,buf1,3); if (ptr > 0) printf("buffer 2 is ...
嵌入式linux_C函数快速参考_IT/计算机_专业资料。嵌入式linux_C函数快速参考... 否则返回小于 0 的整数 strncmp #include <string.h> int strncmp(const ...
linux c 常用函数 -- 内存及字符串操作_IT/计算机_专业资料。linux c 常用...(忽略大小写比较字符串) 相关函数 bcmp,memcmp,strcmp,strcoll,strncmp 表头...
Linux下C函数_IT/计算机_专业资料。1、isalnum 测试字符是否为英文或数字 相关...strncmp 57、strncat 连接两字符串 相关函数:bcopy,memccpy,memecpy,strcpy,...
Linux C函数库参考手册 目录_IT/计算机_专业资料。Linux C函数库参考手册 ...(连接两字符串) strncmp(比较字符串) strncpy(拷贝字符串) strpbrk(查找字符串...
零点起飞学Linux C之Linux C基本应用_计算机软件及应用_IT/计算机_专业资料。...该函数的一般形式为: int strncmp(const char *s1, const char *s2, size...
Linux下常用C语言字符串操作函数_IT/计算机_专业资料。C语言字符串操作经常要...若果没找到则返回 NULL 限定长度的比较,拷贝和追加函数 int strncmp(char *s1...
linux C函数库参考新一篇: Linux下各类TCP网络服务器的实现源代码 第1章 字符...(连接两字符串) strncmp(比较字符串) strncpy(拷贝字符串) strpbrk(查找字符串...
linux下的c库函数目录_计算机软件及应用_IT/计算机_专业资料。第 1 章字符...(连接两字符串) strncmp(比较字符串) strncpy(拷贝字符串) strpbrk(查找字符串...
Linux常用C函数--详解 164页 1下载券 linux下的c库函数大全 10页 免费 ...(); return 0; } 7) strcmp/strncmp 阅读下列程序,并不全缺失部分,然后执行...
热门文档