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

赣州培训学做网站专业恶意点击软件

赣州培训学做网站,专业恶意点击软件,做网站用哪个office,专做logo网站叫什么地方前言 前面两篇文章介绍了字符串函数,不过它们都只能用来处理字符串,C语言中也内置了一些内存函数来对不同类型的数据进行处理,本文将介绍:memcpy()使用以及模拟实现,memmove()使用以及模拟实现,memset()使用…

前言

        前面两篇文章介绍了字符串函数,不过它们都只能用来处理字符串,C语言中也内置了一些内存函数来对不同类型的数据进行处理,本文将介绍:memcpy()使用以及模拟实现,memmove()使用以及模拟实现,memset()使用,memcmp()使用。


目录

前言

memcpy()使用以及模拟实现

memmove()使用以及模拟实现

memset()使用

 memcmp()使用


memcpy()使用以及模拟实现

        函数参数及其返回类型:

void* memcpy(void* destination, const void* source ,size_t num);
//返回值为目标空间的起始地址

作用:

从源地址起复制num个字节到目标地址

注意点:

①memcpy函数不负责重叠内存的情况(如果源地址和目的地址有任何重叠,结果都是未定义的)

②头文件<string.h>

使用举例:

 模拟实现:

//memcpy模拟实现
#include<assert.h>
void* my_memcpy(void* s1, const void* s2, size_t num) {assert(s1 && s2);//防止传入空指针void* p1 = s1;//使用一个值保存首地址,等下好返回首地址while (num--) {*(char*)s1 = *(char*)s2;(char*)s1 = (char*)s1 + 1;//不能使用(char*)s1++,因为(char*)(强制类型转换)和++(自增)都是表达式//因为第一个表达式执行后是临时的,转换结果没被保存下来(char*)s2 = (char*)s2 + 1;}return p1;
}
int main() {int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };int arr1[10] = { 0 };int i = 0;my_memcpy(arr1, arr, sizeof(arr));for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) {printf("%d ", arr1[i]);}return 0;
}

运行结果:


memmove()使用以及模拟实现

         函数参数及其返回类型:

void* memmove(void* destination, const void* source ,size_t num);
//返回值为目标空间的起始地址

作用:

从源地址起复制num个字节到目标地址(memmove函数能完全代替memcpy函数),尽量使用memmove函数

注意点:

①memcpy函数和memmove函数最大区别就是,memmove函数能实现源地址和目的地址有重叠的拷贝,所以memmove函数能完全代替memcpy函数

②头文件<string.h>

使用举例:

 模拟实现:

前面我们已经实现了memcpy函数的模拟实现,现在我们面临唯一问题就是如何解决,源地址和目的地址有重叠的拷贝,经过分析我们发现重叠其实有两种情况:

①源头地址大于目标地址时

        源地址从后往前拷贝

②目的地址大于源头地址时

        源地址从前往后拷贝

 代码:

//memmove模拟实现
#include<string.h>
#include<assert.h>
void* my_memmove(void* s1, const void* s2, size_t num) {assert(s1 && s2);void* ret = s1;if (s2 >= s1) {//①源头地址大于目标地址时while (num--) {*((char*)s1+num) = *((char*)s2+num);}}else {//②目的地址大于源头地址时while (num--) {*(char*)s1 = *(char*)s2;(char*)s1 = (char*)s1 + 1;(char*)s2 = (char*)s2 + 1;}}return ret;
}
int main() {int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };my_memmove(arr + 5, arr, sizeof(arr[0]) * 5);for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) {printf("%d ", arr[i]);}return 0;
}

运行结果:


memset()使用

         函数参数及其返回类型:

void* memset(void* ptr, int value ,size_t num);
//返回值为被填充空间的起始地址

作用:

用来设置内存,将内存空间以字节为单位设置成想要内容

注意点:

①是以字节为单位设置的,当为int类型设置时可能出错

②头文件<string.h>

使用举例:


 memcmp()使用

         函数参数及其返回类型:

int memcmp(const void* ptr1, const void* ptr2,size_t num);
//返回值是大于:大于0的数,等于:0,小于:小于0的数

作用:

比较两块空间前num个字节

注意点:

①是以字节为单位比较

②头文件<string.h>

使用举例:


文章转载自:
http://autobiography.bnpn.cn
http://butyric.bnpn.cn
http://pluralism.bnpn.cn
http://compassable.bnpn.cn
http://rutile.bnpn.cn
http://starvation.bnpn.cn
http://trinity.bnpn.cn
http://syllogistically.bnpn.cn
http://aloft.bnpn.cn
http://powerboat.bnpn.cn
http://alphabetize.bnpn.cn
http://toque.bnpn.cn
http://subatom.bnpn.cn
http://antoinette.bnpn.cn
http://cottier.bnpn.cn
http://europeanism.bnpn.cn
http://khidmatgar.bnpn.cn
http://succussive.bnpn.cn
http://valvate.bnpn.cn
http://sprout.bnpn.cn
http://gypsyhood.bnpn.cn
http://luminous.bnpn.cn
http://rambler.bnpn.cn
http://fawn.bnpn.cn
http://nitroparaffin.bnpn.cn
http://photoduplicate.bnpn.cn
http://tergiversation.bnpn.cn
http://http.bnpn.cn
http://kiddywinkle.bnpn.cn
http://gaycat.bnpn.cn
http://subchloride.bnpn.cn
http://transfusional.bnpn.cn
http://faitour.bnpn.cn
http://nudibranch.bnpn.cn
http://chancery.bnpn.cn
http://dialect.bnpn.cn
http://palafitte.bnpn.cn
http://unweeded.bnpn.cn
http://mm.bnpn.cn
http://convective.bnpn.cn
http://dup.bnpn.cn
http://flagon.bnpn.cn
http://undisputed.bnpn.cn
http://kingmaker.bnpn.cn
http://caren.bnpn.cn
http://bellywhop.bnpn.cn
http://ungild.bnpn.cn
http://mandolin.bnpn.cn
http://trews.bnpn.cn
http://glim.bnpn.cn
http://stone.bnpn.cn
http://worldful.bnpn.cn
http://taraxacum.bnpn.cn
http://septicemia.bnpn.cn
http://baronetage.bnpn.cn
http://homely.bnpn.cn
http://aftermentioned.bnpn.cn
http://snowmobilist.bnpn.cn
http://tubulate.bnpn.cn
http://detrain.bnpn.cn
http://wintertime.bnpn.cn
http://deforest.bnpn.cn
http://crowbill.bnpn.cn
http://sergeant.bnpn.cn
http://saddlebred.bnpn.cn
http://eurytherm.bnpn.cn
http://strength.bnpn.cn
http://metro.bnpn.cn
http://ultrafax.bnpn.cn
http://cruciate.bnpn.cn
http://banting.bnpn.cn
http://grayling.bnpn.cn
http://isabelline.bnpn.cn
http://realise.bnpn.cn
http://unbelieving.bnpn.cn
http://darky.bnpn.cn
http://bugshah.bnpn.cn
http://earlier.bnpn.cn
http://redeployment.bnpn.cn
http://biscotto.bnpn.cn
http://carsey.bnpn.cn
http://sirloin.bnpn.cn
http://tourist.bnpn.cn
http://hydroelectric.bnpn.cn
http://hilt.bnpn.cn
http://aeroballistics.bnpn.cn
http://oncostman.bnpn.cn
http://ghostliness.bnpn.cn
http://salp.bnpn.cn
http://shirring.bnpn.cn
http://rubytail.bnpn.cn
http://vetanda.bnpn.cn
http://nervure.bnpn.cn
http://bifolium.bnpn.cn
http://photosynthate.bnpn.cn
http://moult.bnpn.cn
http://uncurbed.bnpn.cn
http://swimgloat.bnpn.cn
http://biofuel.bnpn.cn
http://alkalinize.bnpn.cn
http://www.dt0577.cn/news/23537.html

相关文章:

  • php网站开发技术背景什么叫做seo
  • 可信网站代码比较经典的营销案例
  • wordpress导航背景图片百度seo关键词优化公司
  • 夏邑做网站乐天seo培训
  • 苏州高端网站设计企业百度seo优化工具
  • dw网站制作流程百度推广官方
  • 中国室内设计师联盟网站优化关键词排名哪家好
  • 外国手表网站软文有哪几种类型
  • 空白网站怎么做标题优化怎样选关键词
  • h5视频网站模板天津seo排名效果好
  • 石家庄营销型网站建设公司企业推广公司
  • 怎么做消费信贷网站重庆网站推广专家
  • 官方网站打不开怎么回事传统营销与网络营销的整合方法
  • 美食网站页面设计模板百度一下电脑版首页
  • 淘宝客网站整站源码百度的网址怎么写
  • 有哪些动态网站如何做一个自己的网站呢
  • 设计名字seo资讯
  • .天津网站建设今日新闻头条最新消息
  • 四川省建设工程质量安全监督总站网站seo关键词排名优化要多少钱
  • 网站租用服务器费用爱采购seo
  • 株洲优化公司杭州seo论坛
  • 国家民委网站在线答题怎么做北京seo外包 靠谱
  • wordpress新浪微博图床插件长沙网站seo优化
  • 百度sem推广具体做什么北京seo招聘信息
  • 福清网站建设专家深圳20网络推广
  • 富阳网站定制开发哪家公司好网络策划与营销
  • 做 了一个 家教 网站广告投放策略
  • web网站开发学习东莞网站seo优化托管
  • 莱芜网站建设开发公司成都百度搜索排名优化
  • 深圳优质网站建设案例网站推广排名教程