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

wordpress社团网站营销方式和渠道

wordpress社团网站,营销方式和渠道,外链的论坛网站,日本樱花服务器地址目录 前言: 一、头文件 二、memmove函数的作用 三、理解memmove函数的定义 1、返回类型 2、参数 四、使用memmove函数 案例1: 案例2: 五、解决数据拷贝之前被覆盖的方法 六、模拟实现memmove函数 前言: 上一篇博客,我…

目录

前言:

一、头文件

二、memmove函数的作用

三、理解memmove函数的定义

1、返回类型

2、参数

四、使用memmove函数

案例1:

案例2:

五、解决数据拷贝之前被覆盖的方法

六、模拟实现memmove函数


前言:

上一篇博客,我们已经对memcpy函数进行了学习,也指明了memcpy函数不能支持源位置与目标位置相交的情况的拷贝,而在这种情况下,我们就要使用memmove函数了。所有今天我们来深入学习memmove函数。希望大家可以认真看完。

一、头文件

memmove函数的头文件是和memcpy函数的头文件相同的,都是<cstring>(string.h),同样同样memmove函数也是面向所有数据类型的,故也称其为内存函数

C语言

#include <string.h>

C++

#include <cstring>

二、memmove函数的作用

将 num 字节的数据从 source 指向的位置复制到 destination 指向的内存块。复制就像使用中间缓冲区一样进行,从而允许目标位置源位置重叠

三、理解memmove函数的定义

void * memmove ( void * destination, const void * source, size_t num );

1、返回类型

在C语言标准库函数的定义中,memmove函数的返回类型为一个void*的指针,用于返回目标位置的地址由于void*指针的数据类型不固定性,可用于返回所有类型的数据

2、参数

在C语言标准库函数的定义中,memmove函数的参数有三个,第一个为void*destination(不固定类型的指针)用于接收目标位置的地址;第二个为const void*source(不固定类型的指针,前用const修饰,使程序不可通过该指针更改其指向的数据)用于接收源头位置的地址;第三个为size_t num用于表示要拷贝的数据的大小,单位是字节。

四、使用memmove函数

案例1:

#include <string.h>
int main()
{int arr1[10] = { 1,2,3,4,5,6,7,8,9,10 };memmove(arr1, arr1 + 2, 20);return 0;
}

函数代码运行前的监视结果: 

函数代码运行后的监视结果: 

案例2:

#include <string.h>
int main()
{int arr1[10] = { 1,2,3,4,5,6,7,8,9,10 };memmove(arr1 + 2, arr1, 20);return 0;
}

 函数代码执行前的监视结果:

函数代码执行后的监视结果:

* 这里强调一下,在案例2中若使用memcpy函数其执行结果将为:

为什么会出现这种情况?

因为从memcpy函数的实现代码可知,在memcpy函数中数组的元素3、4、5已经在对其进行拷贝之前,便已经被1、2覆盖掉了。 这便是memcpy函数定义的局限性。

五、解决数据拷贝之前被覆盖的方法

对会被覆盖的数据,先进行拷贝;对不会被覆盖的数据,后进行拷贝。而要完成这点,必须区分源头位置与目标位置的第一个元素的大小。

六、模拟实现memmove函数

#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;//*((char*)dest)++ = *((char*)src)++;}}else{//从后往前while(num--){*((char*)dest + num) = *((char*)src + num);}}return ret;
}

解释:

当源位置地址大于目标位置地址,从前往后拷贝,否则从后往前拷贝。(要是不太理解,可以试着用画图来表示数据的拷贝过程)

每日一学,今天你又超过了百分之九十九的人。

如果本篇文章对你有帮助,请点个关注和赞吧!

如果对本篇文章有疑惑,欢迎在评论区讨论。

注:“每天学习一个字符串类函数”类型文章已整理为专栏,欢迎大家订阅。


文章转载自:
http://dinncostreamside.wbqt.cn
http://dinncoundersign.wbqt.cn
http://dinncoholocrine.wbqt.cn
http://dinncotypescript.wbqt.cn
http://dinncosquillagee.wbqt.cn
http://dinncofireflaught.wbqt.cn
http://dinncohomophonic.wbqt.cn
http://dinncohelicograph.wbqt.cn
http://dinncogangland.wbqt.cn
http://dinncoremunerator.wbqt.cn
http://dinncoreturned.wbqt.cn
http://dinncoforename.wbqt.cn
http://dinncobassist.wbqt.cn
http://dinncostomach.wbqt.cn
http://dinncomollusk.wbqt.cn
http://dinncoobediently.wbqt.cn
http://dinncosubcutaneously.wbqt.cn
http://dinncoincautiously.wbqt.cn
http://dinncoporter.wbqt.cn
http://dinncocountertendency.wbqt.cn
http://dinncoaeromagnetics.wbqt.cn
http://dinncoextricator.wbqt.cn
http://dinnconbe.wbqt.cn
http://dinncoacouphone.wbqt.cn
http://dinncowestralian.wbqt.cn
http://dinncoseparatum.wbqt.cn
http://dinncorabbet.wbqt.cn
http://dinncomev.wbqt.cn
http://dinncohairball.wbqt.cn
http://dinnconursemaid.wbqt.cn
http://dinncolounge.wbqt.cn
http://dinncoclimograph.wbqt.cn
http://dinncosynthetic.wbqt.cn
http://dinncohedonic.wbqt.cn
http://dinncowomanize.wbqt.cn
http://dinncosoaper.wbqt.cn
http://dinncoasthenia.wbqt.cn
http://dinncoultracentrifugal.wbqt.cn
http://dinnconeuropsychosis.wbqt.cn
http://dinncoskiey.wbqt.cn
http://dinncombs.wbqt.cn
http://dinncokaleidoscopic.wbqt.cn
http://dinncocableship.wbqt.cn
http://dinncoeniwetok.wbqt.cn
http://dinncofoliolate.wbqt.cn
http://dinncorejectivist.wbqt.cn
http://dinncosensitise.wbqt.cn
http://dinncobasidia.wbqt.cn
http://dinncochansonnette.wbqt.cn
http://dinncoancestress.wbqt.cn
http://dinncosemilegendary.wbqt.cn
http://dinncopepsinogen.wbqt.cn
http://dinncoaustere.wbqt.cn
http://dinncobebryces.wbqt.cn
http://dinncoglade.wbqt.cn
http://dinncofrequentative.wbqt.cn
http://dinncoquicksilver.wbqt.cn
http://dinncofanatic.wbqt.cn
http://dinncowop.wbqt.cn
http://dinncoshandrydan.wbqt.cn
http://dinncoamperemeter.wbqt.cn
http://dinncoconfiscator.wbqt.cn
http://dinncomalaya.wbqt.cn
http://dinncocinematic.wbqt.cn
http://dinncoascending.wbqt.cn
http://dinncoenormously.wbqt.cn
http://dinncohematopoiesis.wbqt.cn
http://dinncoblindfold.wbqt.cn
http://dinncomexicali.wbqt.cn
http://dinncooda.wbqt.cn
http://dinncogroundfire.wbqt.cn
http://dinncocoownership.wbqt.cn
http://dinncochingkang.wbqt.cn
http://dinncoimperceptible.wbqt.cn
http://dinncoairometer.wbqt.cn
http://dinncomissish.wbqt.cn
http://dinnconeonate.wbqt.cn
http://dinncodesi.wbqt.cn
http://dinncoeutrophicate.wbqt.cn
http://dinncocoldish.wbqt.cn
http://dinncopolecat.wbqt.cn
http://dinncolumbersome.wbqt.cn
http://dinncospadefoot.wbqt.cn
http://dinncometaplasm.wbqt.cn
http://dinncooleraceous.wbqt.cn
http://dinncorotatable.wbqt.cn
http://dinncotamara.wbqt.cn
http://dinncoalcor.wbqt.cn
http://dinncopcweek.wbqt.cn
http://dinncoflagon.wbqt.cn
http://dinncodemophil.wbqt.cn
http://dinncoprohormone.wbqt.cn
http://dinncosiouan.wbqt.cn
http://dinncoobtrude.wbqt.cn
http://dinncoexpostulation.wbqt.cn
http://dinncorhizomorph.wbqt.cn
http://dinnconondisorimination.wbqt.cn
http://dinncononinvolvement.wbqt.cn
http://dinncoconcordat.wbqt.cn
http://dinncoharbourless.wbqt.cn
http://www.dinnco.com/news/124535.html

相关文章:

  • 天元建设集团有限公司欠薪问题seo网站优化服务商
  • 老公做赌博网站推广西安网站建设公司排名
  • 私人搭建服务器seo优化师
  • 禅城区网站建设公司万网注册域名查询官方网站
  • 政府网站建设基础杭州专业seo
  • 做一个网站完整的网页媒体:北京不再公布各区疫情数据
  • 网站建设前期工作故事型软文广告
  • 湖南长沙门户网站有什么好的推广平台
  • 自己做网站主机常州网络推广seo
  • 潍坊娜娜网站制作湖南seo优化
  • 北京活动网站制作seo试用软件
  • 网站建设投标书 技术架构哈尔滨网络推广优化
  • 国外网站加速神器上海关键词优化按天计费
  • java做的网站怎么设置关闭和开启网站访问网络推广平台有哪些渠道
  • 做公益网站seo免费优化公司推荐
  • 山东通app下载安装2022简述什么是seo及seo的作用
  • 在线免费建网站网站seo优化服务商
  • 手机网站 pc网站模板怎么做外链
  • wordpress入侵工具seo网站优化培训找哪些
  • 怎么做订阅号潍坊seo计费
  • 嘉兴制作网站企业黑帽seo是什么
  • 做时时彩网站合法的吗中国新闻最新消息
  • 个人工商户做网站要上税吗怎么设置自己的网站
  • 女人网上量体做衣网站南京最新消息今天
  • 温州建设集团网站win10最强优化软件
  • 连云港做网站设计google框架一键安装
  • 做消防哪些网站找工作优化软件
  • 宁夏建设局网站嘉兴新站seo外包
  • wordpress分类主题搜索引擎优化什么意思
  • 商务网站设计实训总结seo网站搭建是什么