模拟strncmp( )函数
来源:互联网 发布:网络实名制 郭德纲 编辑:程序博客网 时间:2024/04/19 03:06
代码实现 (环境 Visual Studio 2017)
//1.模拟实现strncmp#include <stdio.h>#include <windows.h>#include <string.h>#include <assert.h>#pragma warning( disable : 4996) int My_strncmp(char * dest, const char *src, size_t n){ int ret = 0; assert(dest); assert(src); while ( n && !(*dest - *src) ) { n--; dest++; src++; } if (n && *dest - *src > 0) { return 1; } else if (n && *dest - *src < 0) { return -1; } return ret;}int main(){ char str1[20] = "123456789"; char str2[20] = "12abcde"; printf("%d\n", strncmp(str1, str2, 5)); //调用系统strncpy printf("%d\n", My_strncmp(str1, str2, 5));//调用My_strncpy system("pause"); return 0;}
阅读全文
0 0
- 模拟strncmp( )函数
- 模拟实现strcmp strncmp函数
- 【C语言】模拟实现strcmp()、strncmp()函数
- strncmp函数
- strncmp() 函数
- strncmp() 函数
- strncmp函数
- strncmp 函数
- strncmp函数
- strncmp函数
- 函数 strncmp
- strncmp函数
- strncmp函数
- strncmp() 函数
- strncmp函数
- strncmp函数
- strncmp函数
- Strncmp函数
- 【大版本】企业级Office套包Spire.Office V2.16.23发布 | 附下载
- vector清空
- 在OpenSUSE42.3里面安装MongoDB
- WIN+Anaconda(python3.6)+Face_recognition安装
- LightOJ
- 模拟strncmp( )函数
- Java集合之面试篇
- windbg调试命令
- FZU
- IntelliJ IDEA 源值1.5已过时,将在未来所有版本中删除
- JavaScript执行机制
- 初用vue2写一个超简陋知乎日报(不与知乎日报api交互)超详细记录
- webRTCTutorial 项目文档目录
- HTTP/2 之服务器推送 (Server Push) 最佳实践