初识strncmp函数
来源:互联网 发布:mysql 5.6 中文手册 编辑:程序博客网 时间:2024/05/16 02:20
函数名: strncmp 功 能: 串比较 用 法: int strncmp(char *str1, char *str2, int maxlen); 说明:此函数功能即比较字符串str1和str2的前maxlen个字符。如果前maxlen字节完全相等,返回值就=0;在前maxlen字节比较过程中,如果出现str1[n]与str2[n]不等,则返回(str1[n]-str2[n])。
程序例:
#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); }- 初识strncmp函数
- strncmp函数
- strncmp() 函数
- strncmp() 函数
- strncmp函数
- strncmp 函数
- strncmp函数
- strncmp函数
- 函数 strncmp
- strncmp函数
- strncmp函数
- strncmp() 函数
- strncmp函数
- strncmp函数
- strncmp函数
- Strncmp函数
- 字符串函数strncmp
- memcmp与strncmp函数
- JavaScript学习之 引用类型
- 优秀程序设计的18大原则
- 【绝对震撼】【绝对刺爆眼】性感美女,囧图爆笑,内涵漫画等等!!超赞应用,男女必备啊~
- Comparison of relational database management systems
- dm8168 vin camera port
- 初识strncmp函数
- 编程加载族文件(Revit2012)
- 设计模式个人所见
- 单文件复制到指定目录和自动运行多个.bat文件实现(2012.06.05)
- Android新手入门 FAQ
- 通过JDBC和Hibernate对Clob和Blob的操作
- American dollars
- Javascript事件绑定的几种方式
- 软件项目管理的十大定律