博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
不使用库函数,编写函数int strcmp(char *source, char *dest) 相等返回0,不等返回-1;
阅读量:3526 次
发布时间:2019-05-20

本文共 575 字,大约阅读时间需要 1 分钟。

#include
int strcmp(char *source, char *dest){ int m,n,i,flag; m = strlen(source); n = strlen(dest); if(m!=n) flag = -1; if(source==NULL&&dest==NULL) { flag = 0; } if(source!=NULL&&dest!=NULL) { while(*source==*dest&&*source!='\0') { source++;dest++; } if(*dest=='\0') flag = 0; else flag = -1; } else flag = -1; return flag;}void main(){ int i; char *str = "hello"; char *str1 = "hello"; i = strcmp(str,str1); printf("%d",i);}

转载地址:http://flkhj.baihongyu.com/

你可能感兴趣的文章
php使用openssl来实现非对称加密
查看>>
pdo如何防止 sql注入
查看>>
myisam和innodb的区别
查看>>
MySQL建表规范与注意事项(个人精华)
查看>>
JDK8接口的新特性
查看>>
synchronized的局限性与lock的好处
查看>>
redis和memcached有什么区别?
查看>>
Spring中的设计模式
查看>>
如何设计一个秒杀系统 -- 架构原则
查看>>
如何设计一个秒杀系统 -- 动静分离方案
查看>>
JWT 快速了解
查看>>
实习日志一
查看>>
排序算法稳定性
查看>>
图算法总结(判断有环、最短路径)
查看>>
spring中的类
查看>>
python练习编程网址
查看>>
Python练习小程序1
查看>>
pytorch用于多标签分类的bceloss
查看>>
C++程序设计:打印杨辉三角形
查看>>
C# 方法内改变参数的引用 不影响方法外的值
查看>>