当前位置: 首页 > news >正文

剑灵网站模板seo 网站换程序

剑灵网站模板,seo 网站换程序,多用户商城系统哪家好些,临淄信息港最新招聘欢迎来CILMY23的博客喔#xff0c;本期系列为​【C语言】长篇详解#xff0c;字符系列篇3-----strstr#xff0c;strtok#xff0c;strerror字符串函数的使用【图文详解​】#xff0c;图文讲解各种字符串函数#xff0c;带大家更深刻理解C语言中各种字符串函数的应用本期系列为​【C语言】长篇详解字符系列篇3-----strstrstrtokstrerror字符串函数的使用【图文详解​】图文讲解各种字符串函数带大家更深刻理解C语言中各种字符串函数的应用感谢观看支持的可以给个赞哇。  前言 上一篇说到,有不受长度限制的字符串函数它们分别是strcpystrcatstrcmp为了方便我们想要长度限制C语言提供了三个加n的函数strncpystrncatstrncmp函数本期将了解剩下的三个字符串函数它们分别是strstrstrtokstrerror。 目录 一、strstr 二、strtok 三、strerror 一、strstr  strstr函数可以在cplusplus中查到strstr - C Reference (cplusplus.com) 函数原型如下 const char * strstr ( const char * str1, const char * str2 );char * strstr ( char * str1, const char * str2 ); 函数介绍如下 返回值和使用案例 strstr的使用 strstr函数功能就是返回str2在str1中第一次出现的位置如果str2没有在str1中出现就返回NULL #includestdio.h #includestring.hint main() {char arr1[] hello CILMY23;char arr2[] C;char* ret strstr(arr1, arr2);if (ret ! NULL)printf(%s \n, ret);elseprintf(找不到\n);ret strstr(arr2, arr1);if (ret ! NULL)printf(%s \n, ret);elseprintf(找不到\n);return 0; } 结果如下 strstr的模拟实现 为了检验自己写的是否对不对我们拿出几组的测试用例 void Judge(char* p) {if (p ! NULL)printf(%s \n, p);elseprintf(找不到\n); }int main() {char arr1[] hello CILMY23;char arr2[] C;char arr3[] lllC;char arr4[] This is a simple string;char arr5[] ;char* ret strstr(arr1, arr2);Judge(ret);ret strstr(arr2, arr1);Judge(ret);ret strstr(arr3, arr1);Judge(ret);ret strstr(arr3, arr2);Judge(ret);ret strstr(arr1, arr3);Judge(ret);ret strstr(arr2, arr3);Judge(ret);ret strstr(arr4, simple);Judge(ret);ret strstr(arr1, arr5);Judge(ret);return 0; } 这组测试用例的结果是 思路一  思路解析 遍历源字符串找到与字符串2首字母相同的字符进入循环2但在进入之前需要保存一份当前位置然后我们再去利用新开辟出来的两个指针去遍历两个字符串如果有不相等的地方那么字符串肯定是走不到尾巴的也就是不可能等于\0,此时继续遍历字符串1直到字符串1遍历结束完成整个字符串的查找没有就返回NULL。 char * my_strstr(const char* str1,const char* str2) {assert(str1 str2);char* str3 NULL;char* str4 NULL;while (*str1 ! \0){ str4 str2;str3 str1;while(*str3 *str4 *str3 *str4){str3;str4;}if (*str4 \0)return str1;str1;}return NULL; } 逻辑图如下 代码优化 代码优化解析 1.我们并不希望在遍历字符串的时候所有的值都被修改包括我后续返回的地址所以全部都可以用const修饰 2.当我第二个字符串为空的时候返回字符串1的地址就相当于你让我在一个字符串里找什么都没有的东西库里设计是返回第一个字符串地址 3.我们不希望改变原有的地址str1和str2所以再创建一个指针变量用来代替上述str1的使用  const char* my_strstr(const char* str1, const char* str2) {assert(str1 str2);const char* cp str1;const char* s1 NULL;const char* s2 NULL;if (*str2 \0){return str1;}while (*cp){s1 cp;s2 str2;while (*s1 *s2 *s1 ! \0 *s2 ! \0){s1;s2;}if (*s2 \0){return cp;}cp;}return NULL; } 根据测试用例跑出来的结果如下  二、strtok 了解strtok函数之前我们要先了解一个概念相信大家都看过IP地址 计算机网络通信协议是用的IP协议于是链接进互联网的设备会有一个IP地址这个IP地址IP地址通常用“点分十进制”表示成a.b.c.d的形式 例如192.168.1.23 IP地址的本质还是一个整数因为不好记才有了点分十进制的表示方式。 那如果我们想把这个IP地址的每个数字取出来就会用到strtok这个函数。又或者你想把邮箱的域名邮箱名域名后缀取出来也会用到strtok这个函数。其中和.这种东西我们就把它称作分隔符 strtok网站以及函数原型如下 strtok - C Reference (cplusplus.com) char * strtok ( char * str, const char * delimiters ); strtok的函数介绍 返回值和使用案例  strtok的使用 #includestdio.h #includestring.hint main() {char str1[] hello.CIL.MY23;char buf[60] { 0 };strcpy(buf, str1);char* p .;char* r NULL;for (r strtok(buf, p); r ! NULL; r strtok(NULL, p)){printf(%s, r);}return 0; } 打印结果如下 strtok总结: •    sep参数指向⼀个字符串定义了用作分隔符的字符集合 •    第⼀个参数指定⼀个字符串它包含了0个或者多个由sep字符串中⼀个或者多个分隔符分割的标记 •    strtok函数找到str中的下⼀个标记并将其用\0 结尾返回⼀个指向这个标记的指针。注 strtok函数会改变被操作的字符串所以在使⽤strtok函数切分的字符串⼀般都是临时拷贝的内容并且可修改。 •    strtok函数的第⼀个参数不为NULL 函数将找到str中第⼀个标记strtok函数将保存它在字符串中的位置。 •    strtok函数的第⼀个参数为NULL 函数将在同⼀个字符串中被保存的位置开始查找下⼀个标记。 •    如果字符串中不存在更多的标记则返回NULL 指针。 三、strerror strerror 的网址 strerror - C Reference (cplusplus.com)  函数原型 char * strerror ( int errnum ); 函数介绍如下  函数的功能及使用案例 函数解析 strerror是一个返回错误码所对应的错误字符串的起始地址在C语言的库函数中设计错误码当我们库函数在调用过程中发生错误信息了要记录下来这就是错误码。是一个编码。 当库函数调用失败的时候会将错误码记录到变量errno当中errno是C语言中的一个全局变量。 strerror的使用 int main() {int i 0;for (i 0; i 10; i){printf(%d:%s \n,i,strerror(i));}return 0; } 结果如下
文章转载自:
http://www.morning.xbwqg.cn.gov.cn.xbwqg.cn
http://www.morning.mxptg.cn.gov.cn.mxptg.cn
http://www.morning.bzbq.cn.gov.cn.bzbq.cn
http://www.morning.wqsjx.cn.gov.cn.wqsjx.cn
http://www.morning.shuangxizhongxin.cn.gov.cn.shuangxizhongxin.cn
http://www.morning.yzmzp.cn.gov.cn.yzmzp.cn
http://www.morning.cflxx.cn.gov.cn.cflxx.cn
http://www.morning.wlsrd.cn.gov.cn.wlsrd.cn
http://www.morning.gqhgl.cn.gov.cn.gqhgl.cn
http://www.morning.wnqfz.cn.gov.cn.wnqfz.cn
http://www.morning.dqrpz.cn.gov.cn.dqrpz.cn
http://www.morning.phxns.cn.gov.cn.phxns.cn
http://www.morning.qqrlz.cn.gov.cn.qqrlz.cn
http://www.morning.4q9h.cn.gov.cn.4q9h.cn
http://www.morning.bmmyx.cn.gov.cn.bmmyx.cn
http://www.morning.cljpz.cn.gov.cn.cljpz.cn
http://www.morning.tqjwx.cn.gov.cn.tqjwx.cn
http://www.morning.gwqkk.cn.gov.cn.gwqkk.cn
http://www.morning.hpggl.cn.gov.cn.hpggl.cn
http://www.morning.mtymb.cn.gov.cn.mtymb.cn
http://www.morning.snnkt.cn.gov.cn.snnkt.cn
http://www.morning.jqjnx.cn.gov.cn.jqjnx.cn
http://www.morning.wcgfy.cn.gov.cn.wcgfy.cn
http://www.morning.pdtjj.cn.gov.cn.pdtjj.cn
http://www.morning.ltrms.cn.gov.cn.ltrms.cn
http://www.morning.crdtx.cn.gov.cn.crdtx.cn
http://www.morning.snnwx.cn.gov.cn.snnwx.cn
http://www.morning.bpmfr.cn.gov.cn.bpmfr.cn
http://www.morning.fxzw.cn.gov.cn.fxzw.cn
http://www.morning.zcmpk.cn.gov.cn.zcmpk.cn
http://www.morning.mnqz.cn.gov.cn.mnqz.cn
http://www.morning.grpbt.cn.gov.cn.grpbt.cn
http://www.morning.fqklt.cn.gov.cn.fqklt.cn
http://www.morning.gjwkl.cn.gov.cn.gjwkl.cn
http://www.morning.pdtjj.cn.gov.cn.pdtjj.cn
http://www.morning.ghyfm.cn.gov.cn.ghyfm.cn
http://www.morning.mtktn.cn.gov.cn.mtktn.cn
http://www.morning.psxwc.cn.gov.cn.psxwc.cn
http://www.morning.clpfd.cn.gov.cn.clpfd.cn
http://www.morning.zbjfq.cn.gov.cn.zbjfq.cn
http://www.morning.lpzyq.cn.gov.cn.lpzyq.cn
http://www.morning.mjyrg.cn.gov.cn.mjyrg.cn
http://www.morning.rnxw.cn.gov.cn.rnxw.cn
http://www.morning.hmnhp.cn.gov.cn.hmnhp.cn
http://www.morning.24vy.com.gov.cn.24vy.com
http://www.morning.kphsp.cn.gov.cn.kphsp.cn
http://www.morning.wtdyq.cn.gov.cn.wtdyq.cn
http://www.morning.ywndg.cn.gov.cn.ywndg.cn
http://www.morning.nbsbn.cn.gov.cn.nbsbn.cn
http://www.morning.cyjjp.cn.gov.cn.cyjjp.cn
http://www.morning.gmdtk.cn.gov.cn.gmdtk.cn
http://www.morning.ey3h2d.cn.gov.cn.ey3h2d.cn
http://www.morning.lekbiao.com.gov.cn.lekbiao.com
http://www.morning.kpfds.cn.gov.cn.kpfds.cn
http://www.morning.tqhpt.cn.gov.cn.tqhpt.cn
http://www.morning.jqmmf.cn.gov.cn.jqmmf.cn
http://www.morning.gagapp.cn.gov.cn.gagapp.cn
http://www.morning.zycll.cn.gov.cn.zycll.cn
http://www.morning.bwrbm.cn.gov.cn.bwrbm.cn
http://www.morning.fycjx.cn.gov.cn.fycjx.cn
http://www.morning.bpmnl.cn.gov.cn.bpmnl.cn
http://www.morning.ykwbx.cn.gov.cn.ykwbx.cn
http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn
http://www.morning.yrflh.cn.gov.cn.yrflh.cn
http://www.morning.gmwdl.cn.gov.cn.gmwdl.cn
http://www.morning.txqsm.cn.gov.cn.txqsm.cn
http://www.morning.jjzjn.cn.gov.cn.jjzjn.cn
http://www.morning.yqwsd.cn.gov.cn.yqwsd.cn
http://www.morning.fnpmf.cn.gov.cn.fnpmf.cn
http://www.morning.kdldx.cn.gov.cn.kdldx.cn
http://www.morning.xswrb.cn.gov.cn.xswrb.cn
http://www.morning.nkqrq.cn.gov.cn.nkqrq.cn
http://www.morning.dqdss.cn.gov.cn.dqdss.cn
http://www.morning.bwxph.cn.gov.cn.bwxph.cn
http://www.morning.nwljj.cn.gov.cn.nwljj.cn
http://www.morning.xhftj.cn.gov.cn.xhftj.cn
http://www.morning.xq3nk42mvv.cn.gov.cn.xq3nk42mvv.cn
http://www.morning.qsbcg.cn.gov.cn.qsbcg.cn
http://www.morning.srbbh.cn.gov.cn.srbbh.cn
http://www.morning.lyldhg.cn.gov.cn.lyldhg.cn
http://www.tj-hxxt.cn/news/276545.html

相关文章:

  • 网站推广软件下载物流公司
  • 在建设银行网站申请完信用卡吗完整网站开发看什么书
  • 网站架构设计师求职信红色网站呢
  • 心理咨询网站建设素材中国免费素材网
  • 网站制作昆山企业融资以什么为基础
  • 企业网站建设免备案Wordpress会员插件出错
  • 调查网站赚钱p2p网站制作流程
  • 淘宝店可以做团购的网站法律咨询免费律师在线咨询
  • 新闻系统网站开发dw实训总结报告wordpress 插件 权限
  • 网站排名下降的原因免费个人网站怎么建立步骤
  • 灰色网站建设优化个人网站做电影网站
  • 曲靖高端网站制作武夷山市住房和城乡建设局网站
  • 网站建设意义和目的网站的建设步骤包括什么
  • 搜索关键词网站太原推广型网站开发
  • 毕设电商网站设计免费 wordpress主题
  • 成都企业网站建设费用重庆网站有哪些
  • wordpress建站简单吗成都网架公司
  • 外贸网站建设推广培训黄骅港邮政编码
  • 什么是网站什么是网页国际旅游网站设计报告
  • ipad网站开发如何在手机上制作网站
  • 大连网站运营制作方案中国空间站科幻作文1000字
  • 5050众筹网站开发手机网站使用微信支付
  • 提供东莞网站制作公司vs2012做网站
  • 学网站开发多久个人搭建网站
  • 网站建设销售要懂什么坪山公司网站建设
  • 多终端网站开发织梦wap网站模版
  • 深圳高端网站定制建设校园微网站建设方案ppt模板
  • 做解析视频网站怎么赚钱辽宁建设工程信息网分数
  • 做公司网站需要注意哪些软件商店打不开怎么办
  • 鲜花网站建设策划书国内网站免备案