编程菜鸟的日记-初学尝试编程-编写函数实现strcmp功能
#include <iostream>
using namespace std;
int mystrcmp(const char *str1,const char *str2)
{
assert(*str1!='\0' && *str2!='\0');
while(*str1!='\0' && *str2!='\0' && *str1==*str2)
{
str1++;
str2++;
}
return *str1-*str2;
}
int main()
{
char str1[]=" ";
char str2[]="abc";
int a=mystrcmp(str1,str2);
cout<<a<<endl;
system("pause");
return 0;
}
编程菜鸟的日记-初学尝试编程-编写函数实现strcmp功能的更多相关文章
- 编程菜鸟的日记-初学尝试编程-编写函数实现strcat
#include <iostream>using namespace std;char *mystrcat(const char *str1,const char *str2){ char ...
- 编程菜鸟的日记-初学尝试编程-编写函数实现strlen功能(总结考察点)
//考察点1:输入参数加const int Mystrlen(const char *str) {//考察点2:断言字符串非0 assert(str!=NULL); int len=0;//考察点3: ...
- 编程菜鸟的日记-初学尝试编程-编写函数实现strcpy功能(总结考察点)
char *Mystrcpy(char *strDest, const char *strSrc) //考察点1:将源字符串加const,表明为输入参数 {//考察点2:对源地址和目的地址的非0断言 ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9
#include <iostream> #include <fstream> #include <cstdlib> #include <string> ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8
#include <iostream> #include <fstream> #include <cstdlib> const int SIZE=20; using ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7
#include <iostream> #include <string> #include <cctype> using namespace std; int m ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6
#include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5
#include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4
#include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...
随机推荐
- Stuck on "Authenticating with iTunes Store"
https://forums.developer.apple.com/thread/76803 Try this, it fixed it for me. Open Terminal and run: ...
- CMake在Visual Studio下保持目录结构
CMake在Visual Studio下保持目录结构 原理 主要通过CMAKE自带函数source_group来设定. 需要把add_executable()函数进行封装,包裹一层source_gro ...
- JVM 方法区内存扩大 以及开启GC
因为应用使用了OSGi框架,<深入理解JAVA虚拟机>中对使用OSGi时可能产生的方法区溢出有所描述 第一部分: 第二部分 可见,OSGi会动态生成大量Class,在OSGi中,即使是同一 ...
- C# 会话,进程,线程,线程安全
会话->进程->线程 b/s网站中,每个用户的访问为一次会话,会话中包含CPU为用户在内存中开辟空间存储的会话信息, 如Session,进程,会话拥有一个进程,同一进程下可以拥有多个线程. ...
- 通过CSS自动截取字符串长度
Table Tr TD的自动换行 <style type="text/css"> table { width: 30em; table-layout: fixed; ...
- php把一些预定义的 HTML 实体转换为字符。
htmlspecialchars_decode() echo htmlspecialchars_decode($condition,ENT_QUOTES) ' 会被转成 单引号
- UOJ#62. 【UR #5】怎样跑得更快 数论 莫比乌斯反演
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ62.html 题解 太久没更博客了,该拯救我的博客了. $$\sum_{1\leq j \leq n} \ ...
- springmvc+ajax——第三讲(post请求)
在ajax01.html中增加个input标签: 在ajax的js中增加: 在controller中仍然使用getParamter():
- 002 如何在一台PC上装两个版本的python
在之前学习爬虫的时候,使用的是python2.7,现在主流已经是3.7了. 在这里,写了一下如何在2.7的基础上安装python3.6 一:检查python版本 1.cmd 二:安装python3 1 ...
- thinkphp验证器
验证器类:$validate=new \think\Validate($rule,$message,$field); 独立验证: //独立验证 $rule=[ 'name' => 'requir ...