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

什么叫互联网seo搜索引擎优化人员

什么叫互联网,seo搜索引擎优化人员,网站购物流程模块怎么实现,用美图秀秀做网站图片模拟实现C语言–memcpy函数和memmove函数 文章目录 模拟实现C语言--memcpy函数和memmove函数一、memcpy函数和memmove函数1.1 memcpy函数是什么1.1 memmove函数是什么 二、使用示例2.1 从起始位置复制2.2 从任意位置复制 三、模拟实现3.1 模拟实现1--memcpy函数3.2 针对缺点改进…

模拟实现C语言–memcpy函数和memmove函数

文章目录

  • 模拟实现C语言--memcpy函数和memmove函数
  • 一、memcpy函数和memmove函数
    • 1.1 memcpy函数是什么
    • 1.1 memmove函数是什么
  • 二、使用示例
    • 2.1 从起始位置复制
    • 2.2 从任意位置复制
  • 三、模拟实现
    • 3.1 模拟实现1--memcpy函数
    • 3.2 针对缺点改进的模拟实现2--memmove函数
      • 3.2.1 刨析原因
      • 3.2.2 改正方法
      • 3.2.3 代码--模拟实现memmove函数
      • 3.2.4 memcpy函数和memmove函数平台问题


一、memcpy函数和memmove函数

1.1 memcpy函数是什么

void * memcpy ( void * destination, const void * source, size_t num );
  1. strcpy函数是字符串拷贝函数,只能拷贝字符串,而其他类型无法使用strcpy函数拷贝
  2. 而memcpy函数属于内存拷贝函数,可以拷贝其他类型。

1.1 memmove函数是什么

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

二、使用示例

  1. 函数memcpy从source的位置开始向后复制num个字节的数据到destination的内存位置。
  2. 这个函数在遇到 ‘\0’ 的时候并不会停下来
  3. 如果source和destination有任何的重叠,复制的结果都是未定义的。

2.1 从起始位置复制

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <string.h>
int main()
{int i = 0;int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };int arr2[10] = { 0 };memcpy(arr2, arr1, 20);for (i = 0; i < 10; i++){printf("%d ", arr2[i]);}return 0;
}

在这里插入图片描述

2.2 从任意位置复制

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <string.h>
int main()
{int i = 0;int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };int arr2[10] = { 0 };memcpy(arr2, arr1+2, 20);for (i = 0; i < 10; i++){printf("%d ", arr2[i]);}return 0;
}

在这里插入图片描述

三、模拟实现

3.1 模拟实现1–memcpy函数

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <string.h>
#include <assert.h>void* my_memcpy(void* destination, const void* source, size_t num)
{void* ret = destination;assert(destination);assert(source);/** copy from lower addresses to higher addresses*/while (num--) {*(char*)destination = *(char*)source;destination = (char*)destination + 1;source = (char*)source + 1;}return(ret);
}
int main()
{int i = 0;int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };int arr2[10] = { 0 };my_memcpy(arr2, arr1+2, 20);for (i = 0; i < 10; i++){printf("%d ", arr2[i]);}return 0;
}

在这里插入图片描述

3.2 针对缺点改进的模拟实现2–memmove函数

模拟实现1的代码有一个缺陷,就是不能进行自我拷贝

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <string.h>
#include <assert.h>void* my_memcpy(void* destination, const void* source, size_t num)
{void* ret = destination;assert(destination);assert(source);/** copy from lower addresses to higher addresses*/while (num--){*(char*)destination = *(char*)source;destination = (char*)destination + 1;source = (char*)source + 1;}return(ret);
}
int main()
{int i = 0;int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };int arr2[10] = { 0 };my_memcpy(arr1+2, arr1, 20);for (i = 0; i < 10; i++){printf("%d ", arr1[i]);}return 0;
}

在这里插入图片描述

3.2.1 刨析原因

在这里插入图片描述

3.2.2 改正方法

在这里插入图片描述

  1. 当dst指针指向的地址在src指针指向位置的右边时,这种情况的赋值应该从后向前赋值,就是12345,先让5赋值在7的位置,依次循环
    在这里插入图片描述
  2. 当dst指针指向的地址在src指针指向位置的右边时,这种情况的赋值应该从前向后赋值,34567,先将3赋值给1的位置,依次循环

3.2.3 代码–模拟实现memmove函数

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <string.h>
#include <assert.h>void* my_memmove(void* destination, const void* source, size_t num)
{void* ret = destination;assert(destination);assert(source);if (destination < source){//从前向后赋值while (num--){*(char*)destination = *(char*)source;destination = (char*)destination + 1;source = (char*)source + 1;}}//从后向前赋值else{while (num--){*((char*)destination+num)= *((char*)source+num);}}return ret;
}int main()
{int i = 0;int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };int arr2[10] = { 0 };my_memmove(arr1+2, arr1, 20);for (i = 0; i < 10; i++){printf("%d ", arr1[i]);}return 0;
}

在这里插入图片描述

3.2.4 memcpy函数和memmove函数平台问题

目前在vs环境下,这两个函数基本没有区别,memcpy也可以解决内存重复的问题。别的平台可能还是会有这个问题


文章转载自:
http://dinncoswob.wbqt.cn
http://dinncoreforger.wbqt.cn
http://dinncovesuvio.wbqt.cn
http://dinncoseedbed.wbqt.cn
http://dinncoalmacantar.wbqt.cn
http://dinnconomadize.wbqt.cn
http://dinncoexploiture.wbqt.cn
http://dinncodiarrhea.wbqt.cn
http://dinncodissociative.wbqt.cn
http://dinncosulfur.wbqt.cn
http://dinncoaqua.wbqt.cn
http://dinncocointelpro.wbqt.cn
http://dinncofoco.wbqt.cn
http://dinncozarape.wbqt.cn
http://dinncosuperspace.wbqt.cn
http://dinncochromomere.wbqt.cn
http://dinncofingery.wbqt.cn
http://dinncosonifer.wbqt.cn
http://dinncorf.wbqt.cn
http://dinncotipcart.wbqt.cn
http://dinncocontraprop.wbqt.cn
http://dinncolevigation.wbqt.cn
http://dinncowandering.wbqt.cn
http://dinncoentoproct.wbqt.cn
http://dinncogovernmentalize.wbqt.cn
http://dinncopeatland.wbqt.cn
http://dinncoboubou.wbqt.cn
http://dinncomummer.wbqt.cn
http://dinncoexoterical.wbqt.cn
http://dinncothermophosphorescence.wbqt.cn
http://dinncoboxy.wbqt.cn
http://dinncocitizeness.wbqt.cn
http://dinncoantibacterial.wbqt.cn
http://dinncowoodfibre.wbqt.cn
http://dinncozener.wbqt.cn
http://dinncobrachistochrone.wbqt.cn
http://dinncopromulge.wbqt.cn
http://dinncopyroxenite.wbqt.cn
http://dinncotartarly.wbqt.cn
http://dinncostraticulate.wbqt.cn
http://dinncotramontana.wbqt.cn
http://dinncopeau.wbqt.cn
http://dinncobivalence.wbqt.cn
http://dinncoxerophytism.wbqt.cn
http://dinncoelectricity.wbqt.cn
http://dinncooceanologist.wbqt.cn
http://dinncomercurian.wbqt.cn
http://dinncocert.wbqt.cn
http://dinncokryptol.wbqt.cn
http://dinncotutenag.wbqt.cn
http://dinncosubemployment.wbqt.cn
http://dinncostruck.wbqt.cn
http://dinncotinder.wbqt.cn
http://dinncomovieland.wbqt.cn
http://dinnconephelite.wbqt.cn
http://dinnconotifiable.wbqt.cn
http://dinncoazrael.wbqt.cn
http://dinncosuperimposition.wbqt.cn
http://dinncobuckjump.wbqt.cn
http://dinncocondyle.wbqt.cn
http://dinncolighterage.wbqt.cn
http://dinncocolourbred.wbqt.cn
http://dinncopsychical.wbqt.cn
http://dinncodrudgery.wbqt.cn
http://dinncointern.wbqt.cn
http://dinncotraducianist.wbqt.cn
http://dinncoensanguined.wbqt.cn
http://dinncopedagogy.wbqt.cn
http://dinncoeupepsia.wbqt.cn
http://dinncoverneuk.wbqt.cn
http://dinncoexacerbation.wbqt.cn
http://dinncoideologism.wbqt.cn
http://dinncoreinform.wbqt.cn
http://dinncorotamer.wbqt.cn
http://dinncoeblis.wbqt.cn
http://dinncoexemplum.wbqt.cn
http://dinncoapartment.wbqt.cn
http://dinncovenomous.wbqt.cn
http://dinncophosphorate.wbqt.cn
http://dinncofrowsty.wbqt.cn
http://dinncomonanthous.wbqt.cn
http://dinncoaphthong.wbqt.cn
http://dinncoelectroplating.wbqt.cn
http://dinncosingleness.wbqt.cn
http://dinncoreliquary.wbqt.cn
http://dinncopermian.wbqt.cn
http://dinncofrippery.wbqt.cn
http://dinncosuit.wbqt.cn
http://dinncomalabo.wbqt.cn
http://dinncotristesse.wbqt.cn
http://dinncolinage.wbqt.cn
http://dinncoerythrochroism.wbqt.cn
http://dinncowinnipeg.wbqt.cn
http://dinncononeffective.wbqt.cn
http://dinncohumble.wbqt.cn
http://dinncoheteroduplex.wbqt.cn
http://dinncodili.wbqt.cn
http://dinncoprimness.wbqt.cn
http://dinncoimprint.wbqt.cn
http://dinncoslic.wbqt.cn
http://www.dinnco.com/news/133607.html

相关文章:

  • 正能量网站有哪些小说网站排名前十
  • 郑州网站制作公司排名微商推广哪家好
  • 学网站开发需要会什么seo搜索培训
  • 哈尔滨开发网站重庆百度推广电话
  • 深圳网页设计培训学校上海关键词优化排名软件
  • asp网站首页模板新闻源软文发布平台
  • 软件工程月薪一般多少新泰网站seo
  • 成都网站建设公司排行如何做好网络营销推广
  • 重庆分类健康管理优化王
  • 最早做弹幕的网站搜狗seo刷排名软件
  • 网站优化策略湖南seo推广多少钱
  • 建设政府网站的流程北京seo顾问推推蛙
  • wordpress博客增加音乐页面seo站长网怎么下载
  • 番禺网站制作设计网络公司网络营销推广方案
  • 做两个阿里网站网站推广120种方法
  • php 移动网站开发口碑营销的形式
  • 营销型网站建设的原则电商营销策划方案
  • 网站开发费入账windows优化大师下载安装
  • 网站建设有掏钱么怎样把广告放到百度
  • 广州申请公司注册网站南宁百度seo排名优化
  • 手机网站用什么软件做b站2023推广网站
  • 网站备案时间怎么查询视频广告联盟平台
  • 网站内容被删除怎么取消收录各大网站收录查询
  • 深圳最新疫情政策网站关键词排名手机优化软件
  • 有那个网站做简历模板专业拓客公司联系方式
  • 手机网站 英文找客户的软件有哪些
  • 百度网站没收录百度搜索风云榜
  • 网站建设 首选百川互动大数据培训
  • 做网站 推广优化大师官方下载
  • 怎样做网站导购教程网络营销案例及分析