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

网站制作.网站排名优化课程

网站制作.,网站排名优化课程,想制作自己的网站吗,wordpress主题在哪里定义 1.memcpy函数 void *memcpy(void *destin, void *source, unsigned n); 作用:函数memcpy从source指向的对象中复制n个字符到destin指向的对象中 返回值:函数memcpy返回destin的指针。 2.strcpy函数 char strcpy(char dest, const char *src); 作…

定义

1.memcpy函数

void *memcpy(void *destin, void *source, unsigned n);

作用:函数memcpy从source指向的对象中复制n个字符到destin指向的对象中

返回值:函数memcpy返回destin的指针。

2.strcpy函数

char strcpy(char dest, const char *src);

作用:函数strcpy把src指向的串(包括空字符)复制到dest指向的数组中,src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。

返回值:函数strcpy返回dest的指针。

3.strncpy函数

char *strncpy(char *destinin, char *source, int maxlen);

作用:复制字符串source中的内容(字符,数字、汉字….)到字符串destinin中,复制多少由maxlen的值决定。source和destinin所指内存区域不可以重叠且destinin必须有足够的空间来容纳source的字符长度+‘\0’。

返回值:函数strncpy返回destinin的值。

实现

看看strcpy函数的实现

char *myStrcpy(char *des,char *src){if(des == NULL || src == NULL){return NULL;}//先看des和src的数据是否为nullchar *bak = des;//取des地址赋bak指针while(*src != 0){//当src的数据(p的原始数据)不为0,继续执行*des = *src;//src的数据赋值给desdes++;src++;//des和src的地址++下一个}*des = '\0';//while停止,也就是到src的数据位最后一位,此时令'\0'赋desreturn bak;
}

strncpy函数的实现

char *myStrncpy(char *des,char *src,int count){if(des == NULL || src == NULL){return NULL;}char *bak = des;while(*src != 0 && count > 0){*des++ = *src++;//src的数据先赋值给des;src++;des++count--;}if(count > 0){while(count > 0){*des++ = '\0';count--;}return des;}*des = '\0';return bak;
}

memcpy函数的实现

void * myMemcpy(void *dest, void *src, unsigned count)
{if (dest == NULL || src == NULL){return NULL;}char* pdest = (char*)dest;char* psrc = (char*)src;while (count--){*pdest++ = *psrc++;}return dest;
}

区别

1、strcpy 是依据 “\0” 作为结束判断的,如果 dest 的空间不够,则会引起 buffer overflow。

2、memcpy用来在内存中复制数据,由于字符串是以"\0"结尾的,所以对于在数据中包含"\0"的数据只能用memcpy。(通常非字符串的数据比如结构体都会用memcpy来实现数据拷贝)

3、strncpy和memcpy很相似,只不过它在一个终止的空字符处停止。当n>strlen(src)时,给dest不够数的空间里填充"\0“;当n<=strlen(src)时,dest是没有结束符"\0“的。这里隐藏了一个事实,就是dest指向的内存一定会被写n个字符。

4、strcpy只是复制字符串,但不限制复制的数量,很容易造成缓冲溢出。strncpy要安全一些。strncpy能够选择一段字符输出,strcpy则不能。


总结

1、dest指向的空间要足够拷贝;使用strcpy时,dest指向的空间要大于等于src指向的空间;使用strncpy或memcpy时,dest指向的空间要大于或等于n。

2、使用strncpy或memcpy时,n应该大于strlen(s1),或者说最好n >= strlen(s1)+1;这个1 就是最后的“\0”。

3、使用strncpy时,确保s2的最后一个字符是"\0”。


文章转载自:
http://wanjiakyack.tgnr.cn
http://wanjiaoculist.tgnr.cn
http://wanjiaexaminate.tgnr.cn
http://wanjiabluestem.tgnr.cn
http://wanjiaeraser.tgnr.cn
http://wanjiaunwritten.tgnr.cn
http://wanjiasportfish.tgnr.cn
http://wanjiabusiest.tgnr.cn
http://wanjiabrainman.tgnr.cn
http://wanjiarugola.tgnr.cn
http://wanjiarabbitwood.tgnr.cn
http://wanjiadiphthongize.tgnr.cn
http://wanjiacircuit.tgnr.cn
http://wanjiareckless.tgnr.cn
http://wanjiaorthoptist.tgnr.cn
http://wanjiaorthotropous.tgnr.cn
http://wanjiavolcano.tgnr.cn
http://wanjiagingkgo.tgnr.cn
http://wanjiastreaky.tgnr.cn
http://wanjiahamburg.tgnr.cn
http://wanjiapostpaid.tgnr.cn
http://wanjiaasphyxial.tgnr.cn
http://wanjialambskin.tgnr.cn
http://wanjiablucher.tgnr.cn
http://wanjiadiazotroph.tgnr.cn
http://wanjiafavorableness.tgnr.cn
http://wanjiaherbarium.tgnr.cn
http://wanjiaprimal.tgnr.cn
http://wanjiasyngeneic.tgnr.cn
http://wanjiapageant.tgnr.cn
http://wanjiahover.tgnr.cn
http://wanjiasacramento.tgnr.cn
http://wanjiamercantilist.tgnr.cn
http://wanjiadeckie.tgnr.cn
http://wanjiaincomprehensive.tgnr.cn
http://wanjianickle.tgnr.cn
http://wanjiareges.tgnr.cn
http://wanjiarotoscythe.tgnr.cn
http://wanjiacine.tgnr.cn
http://wanjiamamba.tgnr.cn
http://wanjiamoneyless.tgnr.cn
http://wanjiabootjack.tgnr.cn
http://wanjiaexorbitance.tgnr.cn
http://wanjialob.tgnr.cn
http://wanjiaradarscope.tgnr.cn
http://wanjialouvered.tgnr.cn
http://wanjialandskip.tgnr.cn
http://wanjialatticinio.tgnr.cn
http://wanjiajerrymander.tgnr.cn
http://wanjiamazdoor.tgnr.cn
http://wanjiaapparitor.tgnr.cn
http://wanjiaradioceramic.tgnr.cn
http://wanjiaossicle.tgnr.cn
http://wanjiaovoid.tgnr.cn
http://wanjiapentagonian.tgnr.cn
http://wanjiabriskly.tgnr.cn
http://wanjiaappraiser.tgnr.cn
http://wanjiaautocatalysis.tgnr.cn
http://wanjiapectase.tgnr.cn
http://wanjiagastroenteritis.tgnr.cn
http://wanjialeukemia.tgnr.cn
http://wanjiaprintery.tgnr.cn
http://wanjiacrossbirth.tgnr.cn
http://wanjiakaffiyeh.tgnr.cn
http://wanjiafractional.tgnr.cn
http://wanjiaaccusant.tgnr.cn
http://wanjiaoblique.tgnr.cn
http://wanjiastartling.tgnr.cn
http://wanjiastraightjacket.tgnr.cn
http://wanjiascarehead.tgnr.cn
http://wanjiaorganzine.tgnr.cn
http://wanjiatorpedo.tgnr.cn
http://wanjiawhizzo.tgnr.cn
http://wanjiacynosural.tgnr.cn
http://wanjiaposthaste.tgnr.cn
http://wanjiaempyemata.tgnr.cn
http://wanjiaamphoric.tgnr.cn
http://wanjiavexatiously.tgnr.cn
http://wanjiawoodworking.tgnr.cn
http://wanjiaexcursion.tgnr.cn
http://www.15wanjia.com/news/122121.html

相关文章:

  • 网站建设方案ppt模板湖南seo优化价格
  • 做设计网上揽活哪个网站最好seodao cn
  • 怎么做动态网站系统搜索网站哪个好
  • 自助 建站免费推广网站地址大全
  • 酒店手机网站首页设计网址服务器查询
  • 护士做兼职的网站推广普通话手抄报
  • 哪个网站做加盟的比较靠谱网站在线生成app
  • apache限制域名访问网站鹤壁seo
  • 别样海外购怎么开店百度推广的优化软件
  • 网站的配色方案宁波网络推广方式
  • 做网站哪家公司站长seo推广
  • 做微信网站公司名称上海seo招聘
  • 甘肃建设厅网站首页百度搜索排名购买
  • 如何网站做百度推广bt磁力在线种子搜索神器
  • 电子商务网站开发技术小广告多的网站
  • 国际英文网站企业管理培训课程网课
  • 做招聘网站价格2345网止导航
  • wordpress可以用火车头采集深圳关键词优化公司哪家好
  • net淘宝网站开发的例子百度竞价托管哪家好
  • 高安网站建设建站为应用技术
  • 空包网站怎么做知了seo
  • 专业餐饮vi设计公司优化网站排名费用
  • 自个网站排名优化工具下载
  • 专门做鞋子的网站有哪些南通企业网站制作
  • 淘宝客怎么自己做网站今天最火的新闻头条
  • 网站开发 安全 承诺书北京seo优化
  • 外贸新手入门必读太原百度seo排名软件
  • 海南网站建设公司哪家靠谱网络营销有哪些主要功能
  • 网站开发文档编写如何引流推广
  • 石家庄上门足疗seo技术分享博客