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

网站建设ui营销渠道的概念

网站建设ui,营销渠道的概念,wordpress flv播放,个人网站可以做资讯吗🚀write in front🚀 📝个人主页:认真写博客的夏目浅石. 🎁欢迎各位→点赞👍 收藏⭐️ 留言📝 📣系列专栏:夏目的C语言宝藏 💬总结:希望你看完之…

在这里插入图片描述

🚀write in front🚀
📝个人主页:认真写博客的夏目浅石.
🎁欢迎各位→点赞👍 + 收藏⭐️ + 留言📝
📣系列专栏:夏目的C语言宝藏
💬总结:希望你看完之后,能对你有所帮助,不足请指正!共同学习交流 🖊
✉️如果无聊的话,就来逛逛我的博客栈吧stack-frame.cn

文章目录

  • 前言
  • 函数介绍以及模拟实现
    • 1.1 strlen函数
    • 1.2 strcpy函数
    • 1.3 strcat函数
    • 1.4 strcmp函数
    • 1.5 strncpy函数
    • 1.6 strncat函数
    • 1.7 strncmp函数
    • 1.8 strstr函数
    • 1.9 strtok函数
    • 1.10 strerror函数
    • 1.11 memcpy函数
    • 1.12 memmove函数
    • 1.13 memcmp函数
  • 总结


前言

函数的学习离不开这些


提示:以下是本篇文章正文内容,下面案例可供参考

函数介绍以及模拟实现

1.1 strlen函数

size_t strlen ( const char * str );
  • 字符串已经'\0' 作为结束标志,strlen函数返回的是在字符串中 '\0' 前面出现的字符个数(不包含 '\0' )。
  • 参数指向的字符串必须要以 '\0' 结束。
  • 注意函数的返回值为size_t,是无符号的

设置为size_t的原因介绍:

strlen求字符串长度的,求出的长度是不可能为负数的
所以返回类型设置为size_t也是合情合理的
typedef unsigned int size_t

验证代码:

#include<stdio.h>
#include<string.h>int main()
{//数学上:3-6=-3;//实际上:size_t所以俩差值是一个很大的数 if(strlen("abc") - strlen("abcdef") > 0){printf(">\n");}else{printf("<=\n");}return 0;
}

运行图示:
在这里插入图片描述

strlen函数的模拟实现

方法一:遍历法

#include<stdio.h>
#include<assert.h>
int my_strlen(char* str)
{assert(str != NULL);int cnt=0;while(*str!='\0'){cnt++;str++;}return cnt;
}
int main()
{char arr[]="abcdef";int len=my_strlen(arr);printf("%d\n",len);return 0;
}

方法二:递归法

#include<stdio.h>
#include<assert.h>
int my_strlen(const char* str)
{assert(str!=NULL);if(*str!='\0')return 1+my_strlen(str+1);else return 0;
}
int main()
{char arr[]="abcdef";int len=my_strlen(arr);printf("%d\n",len);return 0;
}

方法三:减指法

#include<stdio.h>
#include<assert.h>
int my_strlen(const char* str)
{assert(str!=NULL);if(*str!='\0')return 1+my_strlen(str+1);else return 0;
}
int main()
{char arr[]="abcdef";int len=my_strlen(arr);printf("%d\n",len);return 0;
}

1.2 strcpy函数

char* strcpy(char * destination, const char * source );
  • Copies the C string pointed by source into the array pointed by destination, including theterminating null character (and stopping at that point).
  • 源字符串必须以 '\0' 结束。
  • 会将源字符串中的 '\0' 拷贝到目标空间。
  • 目标空间必须足够大,以确保能存放源字符串。
  • 目标空间必须可变。

strcpy函数的模拟实现

方法一:遍历法

#include<stdio.h>
#include<assert.h>
char* my_strcpy(char* dest , const char* src)
{char *ret=dest;assert(dest&&src);while(*dest++ = *src++){;}return ret;
}int main()
{char arr[]="xxxxxxxxxx";char a[]="abcdef";my_strcpy(arr,a);printf("%s",arr);return 0;
}

方法二:遍历法

#include<stdio.h>
#include<assert.h>
void my_strcpy(const char*str,char* ptr)
{assert(str!=NULL);assert(ptr!=NULL);while(*str!='\0'){*ptr=*str;str++;ptr++;}
}
int main()
{char arr[]="xxxxxxxxxx";char a[]="abcdef";my_strcpy(arr,a);printf("%s",arr);return 0;
}

1.3 strcat函数

char * strcat ( char * destination, const char * source );
  • Appends a copy of the source string to the destination string. The terminating null characterin destination is overwritten by the first character of source, and a null-character is includedat the end of the new string formed by the concatenation of both in destination.
  • 源字符串必须以 '\0' 结束。
  • 目标空间必须有足够的大,能容纳下源字符串的内容。
  • 目标空间必须可修改。

函数的使用:

#include<stdio.h>
#include<assert.h>
#include<string.h>int main()
{char arr[20]="hello ";strcat(arr,"world");printf("%s",arr); return 0;
}

在这里插入图片描述

strcat函数的模拟实现

#include<stdio.h>
#include<assert.h>
#include<string.h>char* my_strcat(char* dest,const char* src)
{assert(dest && src);char* start= dest;//1.寻找'\0'while(*dest){dest++;}//2.追加while(*dest++ = *src++){;}return start; 
}int main()
{char arr[20]="hello ";my_strcat(arr,"world");printf("%s",arr); return 0;
}

1.4 strcmp函数

int strcmp ( const char * str1, const char * str2 );
  • This function starts comparing the first character of each string. If they are equal to eachother, it continues with the following pairs until the characters differ or until a terminatingnull-character is reached.
  • 第一个字符串大于第二个字符串,则返回大于0的数字
  • 第一个字符串等于第二个字符串,则返回0
  • 第一个字符串小于第二个字符串,则返回小于0的数字

strcmp函数的模拟实现

#include<stdio.h>
#include<string.h>
#include<assert.h>int my_strcmp(const char* str1,const char* str2)
{assert(str1 && str2);while(*str1 == *str2){if(*str1=='\0')return 0;str1++;str2++;}
//	if(*str1 > *str2)
//		return 1;
//	else
//		return -1;return *str1 - *str2;
}int main()
{char arr1[]="ab";char arr2[]="abcde";int ret=my_strcmp(arr1,arr2);printf("%d\n",ret);return 0;
}

1.5 strncpy函数

char * strncpy ( char * destination, const char * source, size_t num );
  • Copies the first num characters of source to destination. If the end of the source C string(which is signaled by a null-character) is found before num characters have been copied,destination is padded with zeros until a total of num characters have been written to it.
  • 拷贝num字符从源字符串到目标空间。
  • 如果源字符串的长度小于num,则拷贝完源字符串之后,在目标的后边追加0,直到num个。

函数的使用:

#include<stdio.h>
#include<string.h>
#include<assert.h>int main()
{char arr1[20]="xxxxxxxxxx";strncpy(arr1,"abcdef",3);printf("%s\n",arr1);return 0;
}

在这里插入图片描述

1.6 strncat函数

char * strncat ( char * destination, const char * source, size_t num );
  • Appends the first num characters of source to destination, plus a terminating null-character.
  • If the length of the C string in source is less than num, only the content up to the terminatingnull-character is copied

函数的使用:

#include <stdio.h>
#include <string.h>
int main ()
{char str1[20];char str2[20];strcpy (str1,"To be ");strcpy (str2,"or not to be");strncat (str1, str2, 6);puts (str1);return 0;
}

1.7 strncmp函数

int strncmp ( const char * str1, const char * str2, size_t num );

函数的使用:

#include <stdio.h>
#include <string.h>
int main ()
{char str[][5] = { "R2D2" , "C3PO" , "R2A6" };int n;puts ("Looking for R2 astromech droids...");for (n=0 ; n<3 ; n++)if (strncmp (str[n],"R2xx",2) == 0){printf ("found %s\n",str[n]);}return 0;
}

1.8 strstr函数

char * strstr ( const char *str1, const char * str2);
  • Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1.

函数的使用:

#include<stdio.h>
#include<string.h>
#include<assert.h>int main()
{char arr1[]="abbbbcdef";char arr2[]="bbcd";char* ret=strstr(arr1,arr2);if(ret==NULL){printf("找不到\n");}	else{printf("%s\n",ret); }return 0;
}

模拟实现:

#include<stdio.h>
#include<string.h>
#include<assert.h>char* my_strstr(char* str1,char* str2)
{assert(str1&&str2);if(*str2=='\0'){return str1;}char* s1=str1;char* s2=str2;char* cp=str1;while(*cp){s1=cp;s2=str2;while(*s1!='\0' && *s2!='\0' && *s1==*s2){++s1;++s2;}if(*s2=='\0'){return cp;}cp++;}return NULL;
}int main()
{char arr1[]="abbbbcdef";char arr2[]="bbcd";char* ret= my_strstr(arr1,arr2);if(ret==NULL){printf("找不到\n");}	else{printf("%s\n",ret); }return 0;
}

1.9 strtok函数

char * strtok ( char * str, const char * sep );
  • sep参数是个字符串,定义了用作分隔符的字符集合
  • 第一个参数指定一个字符串,它包含了0个或者多个sep字符串中一个或者多个分隔符分割的标记。
  • strtok函数找到str中的下一个标记,并将其用 \0 结尾,返回一个指向这个标记的指针。(注:
    strtok函数会改变被操作的字符串,所以在使用strtok函数切分的字符串一般都是临时拷贝的内容
    并且可修改。)
  • strtok函数的第一个参数不为 NULL ,函数将找到str第一个标记strtok函数将保存它在字符串中的位置。
  • strtok函数的第一个参数NULL函数将在同一个字符串中被保存的位置开始,查找下一个标
    记。
  • 如果字符串中不存在更多的标记,则返回 NULL 指针。
#include<stdio.h>
#include<string.h>int main()
{char arr[]="192#168.120.85";char* p="#.";char buf[20]={0};strcpy(buf,arr);char* ret=NULL;for(ret=strtok(buf,p);ret!=NULL;ret=strtok(NULL,p)){printf("%s\n",ret);}return 0;
}

1.10 strerror函数

char * strerror ( int errnum );
  • 返回错误码,所对应的错误信息。

在这里插入图片描述

1.11 memcpy函数

void * memcpy ( void * destination, const void * source, size_t num );
  • 函数memcpysource的位置开始向后复制num个字节的数据到destination的内存位置。
  • 这个函数在遇到 '\0' 的时候并不会停下来
  • 如果sourcedestination有任何的重叠,复制的结果都是未定义的

模拟实现:

#include<stdio.h>
#include<string.h>
#include<assert.h>void* my_memcpy(void* dest,const void* src,size_t num)
{void* ret=dest;assert(dest&&src);while(num--){*(char*)dest=*(char*)src;dest=(char*)dest+1;src=(char*)src+1;}return ret;
}int main()
{int arr1[]={1,2,3,4,5,6,7,8,9,10};int arr2[10]={0};my_memcpy(arr2,arr1+2,20);return 0;
}

1.12 memmove函数

void * memmove ( void * destination, const void * source, size_t num );
  • memcpy的差别就是memmove函数处理的源内存块和目标内存块是可以重叠的。
  • 如果源空间和目标空间出现重叠,就得使用memmove函数处理。

模拟实现:

#include<stdio.h>
#include<assert.h>void* my_memmove(void* dest,const void* src,size_t num)
{void* ret=dest;assert(dest&&src);if(dest<src){while(num--){*(char*)dest=*(char*)src;dest=(char*)dest+1;src=(char*)src+1;}}else{while(num--){*((char*)dest+num)=*((char*)src+num);}}return ret;
}int main()
{int arr[]={1,2,3,4,5,6,7,8,9,10};my_memmove(arr,arr+2,20);for(int i=0;i<10;i++){printf("%d ",arr[i]);}puts("");return 0;
}

1.13 memcmp函数

int memcmp ( const void * ptr1, const void * ptr2, size_t num );
  • 比较从ptr1和ptr2指针开始的num个字节
  • 返回值如下:
    在这里插入图片描述
#include<stdio.h>
#include<string.h>int main()
{int arr1[]={1,2,6};int arr2[]={1,2,5};int ret=memcmp(arr1,arr2,9);printf("%d\n",ret);return 0;
}

在这里插入图片描述

总结

本期学习了很多字符串相关的函数,包括基本用法和模拟实现,都给大家书写了出来,希望大家可以多敲一遍加深对于函数的印象

我是夏目浅石,希望和你一起学习进步,刷题无数!!!希望各位大佬能一键三连支持一下博主,hhhh~我们下期见喽

在这里插入图片描述
如果无聊的话,就来逛逛我的博客栈吧stack-frame.cn

原创不易,还希望各位大佬支持一下\textcolor{blue}{原创不易,还希望各位大佬支持一下}原创不易,还希望各位大佬支持一下

👍 点赞,你的认可是我创作的动力!\textcolor{9c81c1}{点赞,你的认可是我创作的动力!}点赞,你的认可是我创作的动力!

⭐️ 收藏,你的青睐是我努力的方向!\textcolor{ed7976}{收藏,你的青睐是我努力的方向!}收藏,你的青睐是我努力的方向!

✏️ 评论,你的意见是我进步的财富!\textcolor{98c091}{评论,你的意见是我进步的财富!}评论,你的意见是我进步的财富!


文章转载自:
http://epicentrum.nrpp.cn
http://extensive.nrpp.cn
http://mesosphere.nrpp.cn
http://crayonist.nrpp.cn
http://ephedrine.nrpp.cn
http://furtive.nrpp.cn
http://tollgatherer.nrpp.cn
http://rhizanthous.nrpp.cn
http://anapest.nrpp.cn
http://stillborn.nrpp.cn
http://disaffirm.nrpp.cn
http://widthways.nrpp.cn
http://gazer.nrpp.cn
http://marque.nrpp.cn
http://immunise.nrpp.cn
http://kuomintang.nrpp.cn
http://checkroom.nrpp.cn
http://quantify.nrpp.cn
http://honeymoon.nrpp.cn
http://anacoluthia.nrpp.cn
http://ungrounded.nrpp.cn
http://condescending.nrpp.cn
http://penuchle.nrpp.cn
http://bridgetown.nrpp.cn
http://metre.nrpp.cn
http://evulsion.nrpp.cn
http://veinstone.nrpp.cn
http://kyat.nrpp.cn
http://senatus.nrpp.cn
http://galahad.nrpp.cn
http://calomel.nrpp.cn
http://willpower.nrpp.cn
http://centavo.nrpp.cn
http://absorberman.nrpp.cn
http://triangulate.nrpp.cn
http://developing.nrpp.cn
http://wooingly.nrpp.cn
http://gallisize.nrpp.cn
http://accentuation.nrpp.cn
http://arthrotomy.nrpp.cn
http://pyrosis.nrpp.cn
http://sarcosine.nrpp.cn
http://inby.nrpp.cn
http://woolhat.nrpp.cn
http://multiflex.nrpp.cn
http://isotope.nrpp.cn
http://dazed.nrpp.cn
http://extirpate.nrpp.cn
http://pugilist.nrpp.cn
http://stenography.nrpp.cn
http://albizzia.nrpp.cn
http://ghettoize.nrpp.cn
http://uric.nrpp.cn
http://manipulator.nrpp.cn
http://hatchel.nrpp.cn
http://bloomery.nrpp.cn
http://megaric.nrpp.cn
http://adae.nrpp.cn
http://bivariate.nrpp.cn
http://bosk.nrpp.cn
http://hydrophytic.nrpp.cn
http://diseased.nrpp.cn
http://aldo.nrpp.cn
http://diatropism.nrpp.cn
http://bikky.nrpp.cn
http://stringy.nrpp.cn
http://childe.nrpp.cn
http://exploitee.nrpp.cn
http://tola.nrpp.cn
http://ericoid.nrpp.cn
http://immunoadsorbent.nrpp.cn
http://ackemma.nrpp.cn
http://leukosis.nrpp.cn
http://droshky.nrpp.cn
http://estuary.nrpp.cn
http://viscerocranium.nrpp.cn
http://macao.nrpp.cn
http://snowbrush.nrpp.cn
http://analogous.nrpp.cn
http://anguilla.nrpp.cn
http://nonresistant.nrpp.cn
http://interindividual.nrpp.cn
http://belted.nrpp.cn
http://pastelist.nrpp.cn
http://pung.nrpp.cn
http://violate.nrpp.cn
http://impregnatable.nrpp.cn
http://regrate.nrpp.cn
http://neutralization.nrpp.cn
http://semiangle.nrpp.cn
http://cinque.nrpp.cn
http://granadero.nrpp.cn
http://filigreework.nrpp.cn
http://stearate.nrpp.cn
http://yatata.nrpp.cn
http://hayfield.nrpp.cn
http://plenty.nrpp.cn
http://yha.nrpp.cn
http://whatnot.nrpp.cn
http://micra.nrpp.cn
http://www.dt0577.cn/news/95846.html

相关文章:

  • 苏州网站建设营销q479185700刷屏百度免费网站制作
  • 网站文字不能复制怎么做郴州网络推广公司排名
  • 在什么网站可以做硬件项目广州seo推广营销
  • 静态网站设计怎么做江阴百度推广公司
  • 铁岭开原网站建设淘宝搜索关键词查询工具
  • 西安响应式网站设计网络推广员有前途吗
  • 企业网站建设好的案例网站制作策划
  • 中小型企业 公司网站建设搜索引擎营销的方法包括
  • 网络运营者应当制定网络安全事件应急预案seo网站免费优化软件
  • 哪些网站适合花钱做推广新手做电商怎么起步
  • wordpress显示默认昵称seo排名优化北京
  • 网站建设课程总结报告seo全站优化全案例
  • 新乡网站建设网络营销专业是干嘛的
  • 企业网站能个人备案吗seo技巧分享
  • 北京网站建设公司华网天下官网安卓神级系统优化工具
  • 安徽安庆网站建设公司北京网站优化策略
  • 新网站该如何做网站优化呢seo优化在哪里学
  • 免费制作自己的微网站网络营销的工作内容包括哪些
  • 巴彦淖尔市做网站公司app推广活动策划方案
  • 做竞价的网站做优化有效果吗朋友圈广告
  • 石家庄企业如何建网站百度总部投诉电话
  • 竞价sem托管百度seo推广免费
  • 无锡品牌网站建设介绍韩国日本比分
  • 做建筑材料哪个网站好一点网络运营
  • wordpress字段管理湖北seo关键词排名优化软件
  • 360建筑网挂靠官网软件下载深圳专门做seo的公司
  • 在国外的网站做推广方案网络舆情应急预案
  • 西安制作网站公司简介一手渠道推广平台
  • 花店网站建设方案谷歌广告投放教程
  • 象山做网站cpa推广接单平台