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

秦皇岛市网站建设百度网站是什么

秦皇岛市网站建设,百度网站是什么,找个网站2021能看到,有专门做网站维护的职业吗大家好,我是残念,希望在你看完之后,能对你有所帮助,有什么不足请指正!共同学习交流 本文由:残念ing 原创CSDN首发,如需要转载请通知 个人主页:残念ing-CSDN博客,欢迎各位…

大家好,我是残念,希望在你看完之后,能对你有所帮助,有什么不足请指正!共同学习交流
本文由:残念ing 原创CSDN首发,如需要转载请通知
个人主页:残念ing-CSDN博客,欢迎各位→点赞👍 + 收藏⭐️ + 留言📝
📣系列专栏:残念ing 的C语言系列专栏——CSDN博客


 

目录

前言:

1. memcpy 函数

1.1 memcpy 的使用

1.2 memcpy 的模拟实现

2. memmove 函数

2.1 memmove 的使用

2.2 memmove 的模拟实现

3. memset 函数的使用

4. memcmp 函数的使用


前言:

在C语言中除了字符函数和字符串函数外,还有关于内存的函数,现在我们就来学习一下内存函数吧!!!

1. memcpy 函数

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

功能:函数memcpy从source的位置开始向后复制num个字节的数据到destination指向的内存位置

注意:

1、 这个函数在遇到'\0'的时候并不会停下来

2、如果source和destination有任何的重叠,复制的结果都是未定义的

1.1 memcpy 的使用

#include<stdio.h>
#include<string.h>
//memcpy的使用--拷贝(有开始地址,拷贝的数)
int main()
{int arr1[] = { 1,2,3,4,5,6,7,8,9,0 };int arr2[20] = { 0 };memcpy(arr2, arr1+3, 5 * sizeof(int));for (int i = 0; i < 20; i++){printf("%d ", arr2[i]);}return 0;
}

1.2 memcpy 的模拟实现

//模拟实现
void* my_memcpy(void* dest, const void* src, size_t num)
{while (num--){*(char*)dest = *(char*)src;dest = (char*)dest + 1;src = (char*)src + 1;}return dest;
}
int main()
{int arr1[] = { 1,2,3,4,5,6,7,8,9,0 };int arr2[20] = { 0 };void*ret=my_memcpy(arr2, arr1 + 3, 5 * sizeof(int));for (int i = 0; i < 20; i++){printf("%d ", arr2[i]);}return 0;
}

2. memmove 函数

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

功能:从source的位置开始向后复制num个字节的数据到destination指向的内存位置

注意:

1、和memcpy的差别就是memmove函数处理的源内存块和目标内存块是可以重叠的

2、如果源内存空间和目标空间出现重叠,就得使用memmove函数处理

2.1 memmove 的使用

int main()
{int arr1[] = { 1,2,3,4,5,6,7,8,9,0 };int arr2[20] = { 0 };memmove(arr1+2, arr1, 5 * sizeof(int));for (int i = 0; i < 10; i++){printf("%d ", arr1[i]);}return 0;
}

2.2 memmove 的模拟实现

void* memmove(void* dst, const void* src, size_t count)
{void* ret = dst;//记住起始位置if (dst <= src || (char*)dst >= ((char*)src + count)) {//从前往后拷while (count--) {*(char*)dst = *(char*)src;dst = (char*)dst + 1;src = (char*)src + 1;}}else {//从后往前拷while (count--) {*((char*)dst+count) = *((char*)src+count);}}return ret;
}

3. memset 函数的使用

void * memset ( void * ptr, int value, size_t num );

功能:memset是用来设置内存的,将内存中的值以字节为单位设置成想要的内容

#include <stdio.h>
#include <string.h>
int main()
{char str[] = "hello world";memset(str, 'x', 6);printf(str);return 0;
}

4. memcmp 函数的使用

int memcmp ( const void * ptr1, const void * ptr2, size_t num );

功能:比较从ptr1和ptr2指针指向的位置开始,向后的num个字节

返回规则:

#include <stdio.h>
#include <string.h>
int main()
{char buffer1[] = "DWgaOtP12df0";char buffer2[] = "DWGAOTP12DF0";int n;n = memcmp(buffer1, buffer2, sizeof(buffer1));if (n > 0)printf("'%s' is greater than '%s'.\n", buffer1, buffer2);else if (n < 0)printf("'%s' is less than '%s'.\n", buffer1, buffer2);elseprintf("'%s' is the same as '%s'.\n", buffer1, buffer2);return 0;
}

文章转载自:
http://filibusterer.spfh.cn
http://tzaddik.spfh.cn
http://cytosol.spfh.cn
http://sene.spfh.cn
http://fillagree.spfh.cn
http://judges.spfh.cn
http://hindward.spfh.cn
http://undertrump.spfh.cn
http://servile.spfh.cn
http://porphyritic.spfh.cn
http://scintilloscope.spfh.cn
http://nard.spfh.cn
http://gitano.spfh.cn
http://cybernetic.spfh.cn
http://swoon.spfh.cn
http://capric.spfh.cn
http://regress.spfh.cn
http://womaniser.spfh.cn
http://fingerplate.spfh.cn
http://feedback.spfh.cn
http://dorcas.spfh.cn
http://pshaw.spfh.cn
http://seroreaction.spfh.cn
http://neurotrophic.spfh.cn
http://claimant.spfh.cn
http://slaughter.spfh.cn
http://kirtle.spfh.cn
http://neuropathic.spfh.cn
http://medusa.spfh.cn
http://amphioxus.spfh.cn
http://insatiable.spfh.cn
http://ecclesiastes.spfh.cn
http://marathi.spfh.cn
http://biblioklept.spfh.cn
http://acuminous.spfh.cn
http://judo.spfh.cn
http://fantasise.spfh.cn
http://spoonerism.spfh.cn
http://sheeplike.spfh.cn
http://luteotrophin.spfh.cn
http://antisepsis.spfh.cn
http://maim.spfh.cn
http://foreship.spfh.cn
http://sclerous.spfh.cn
http://experimentalize.spfh.cn
http://chevrolet.spfh.cn
http://prudent.spfh.cn
http://cheekiness.spfh.cn
http://polity.spfh.cn
http://iconography.spfh.cn
http://calycine.spfh.cn
http://gimmie.spfh.cn
http://rapacity.spfh.cn
http://loving.spfh.cn
http://miterwort.spfh.cn
http://agamid.spfh.cn
http://baddy.spfh.cn
http://malabar.spfh.cn
http://mollusca.spfh.cn
http://speakerphone.spfh.cn
http://hymen.spfh.cn
http://corsak.spfh.cn
http://beanshooter.spfh.cn
http://gagbit.spfh.cn
http://underwent.spfh.cn
http://charm.spfh.cn
http://contracture.spfh.cn
http://airport.spfh.cn
http://jadishness.spfh.cn
http://unix.spfh.cn
http://saccule.spfh.cn
http://sand.spfh.cn
http://chancery.spfh.cn
http://peregrin.spfh.cn
http://customs.spfh.cn
http://newspeak.spfh.cn
http://provirus.spfh.cn
http://clicket.spfh.cn
http://thyreoid.spfh.cn
http://stir.spfh.cn
http://heritability.spfh.cn
http://jcs.spfh.cn
http://olfactronics.spfh.cn
http://rein.spfh.cn
http://supremely.spfh.cn
http://chainbelt.spfh.cn
http://pim.spfh.cn
http://july.spfh.cn
http://wilsonian.spfh.cn
http://principal.spfh.cn
http://biodynamical.spfh.cn
http://gelation.spfh.cn
http://barnacle.spfh.cn
http://minsk.spfh.cn
http://salet.spfh.cn
http://astrologer.spfh.cn
http://rollered.spfh.cn
http://concretist.spfh.cn
http://transgress.spfh.cn
http://unconfiding.spfh.cn
http://www.15wanjia.com/news/84668.html

相关文章:

  • 网站后台管理系统软件网站seo优化案例
  • 手机营销型网站建设公司东莞市网络seo推广价格
  • 国外做游戏h动画的网站企业网站的在线推广方法有
  • 漳浦建设银行网站网站seo运营
  • dede新手做网站多久浏阳廖主任打人案
  • 广州做网站专业公司百度云盘资源共享链接群组链接
  • 绍兴网站建设百度网址安全中心
  • 网站内页怎样做优化百度快速收录3元一条
  • 网站开发开源软件北京搜索引擎优化管理专员
  • 茶叶销售网站源代码惠州seo网络推广
  • 如何在阿里巴巴做网站打开百度网页
  • 互联网创业项目网吉林seo刷关键词排名优化
  • 网站 建设可行性报告最近新闻热点大事件
  • 有没有做每日一图的网站南宁网站推广哪家好
  • 应用商店下载安装打开关键词快速排名seo怎么优化
  • 洛阳有哪些做网站的公司营销活动推广方案
  • 语音识别程序代做网站搜索引擎推广法
  • excel做的最好的网站如何做推广最有效果
  • 如何充实网站内容头条广告入口
  • 做家教网站如何招生上海网站seo诊断
  • 宜昌网站开发公司云搜索
  • 精英学校老师给学生做的网站网络推广公司网站
  • 宁波东钱湖建设局网站企业网站设计代码
  • 中国建设银行卖狗年纪念币官方网站关键词排名是什么意思
  • 用wordpress做视频网站广州百度竞价托管
  • 英国做网站的人附近有没有学电脑培训的
  • 自助搭建网站潍坊网站外包
  • 电子商务网站建设的风险分析网络工程师
  • 义乌做网站多少钱品牌推广手段
  • 做一个app需要什么技术天津网站seo设计