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

企业电子商务网站建设教案草莓永久地域网名入2022

企业电子商务网站建设教案,草莓永久地域网名入2022,md风格WordPress,用dreamweaver做网站一、malloc函数 1、什么是malloc函数 malloc是memery(内存)和allocate(分配)的缩写,顾名思义,malloc函数为动态分配内存的意思 2、malloc函数语句 int *p(int *)malloc(sizeof(int))malloc函数的形参为申请的内存空间大小,上述申请了一个i…

一、malloc函数

1、什么是malloc函数

malloc是memery(内存)和allocate(分配)的缩写,顾名思义,malloc函数为动态分配内存的意思 

2、malloc函数语句

int *p=(int *)malloc(sizeof(int))
malloc函数的形参为申请的内存空间大小,上述申请了一个int型数据的大小
malloc函数的返回值是这一块内存空间的首地址,上述代码即是将指针变量p指向这动态申请内存的首地址。
(*int)强制类型转换,即将该返回的地址类型强制转换为一个整型变量的地址,也就是说p和p+1相差
一个整型大小。
上述代码一个申请了12个字节的内存大小,p变量占8个字节(与cpu的大小有关),
p指向的内存为4个字节。
p本身的内存是静态分配的,p指向的内存是动态分配的
free(p)把p指向的内存释放掉,而p本身的内存只能由程序执行完毕,系统自动释放

3、malloc函数的用法

int *parry=(int *)malloc(sizeof(int*5);
动态申请5个整型变量大小的内存,即20个字节,parry指针变量指向的是该内存的首地址,
int * 表示该指针变量只能指向int型变量的地址,故parry等价于指向前4个字节,
*parry等价于parry[0];
#include <stdio.h>
#include <malloc.h>
int main()
{int *parry = (int *)malloc(sizeof(int) * 5);for (int i = 0; i < 5; i++){printf("请输入%d个元素的值\n", i + 1);scanf("%d", &parry[i]);}for (int i = 0; i < 5; i++){printf("第%d的值为 %d \n", i + 1, parry[i]);}return 0;
}

在这里插入图片描述

创建动态数组的好处

  • 1、动态的决定数组的大小
  • 2、数组可以由程序员动态的创建和释放
  • 3、数组可跨函数使用

4、初始化内存空间

以mem开头的函数被编入字符串标准库,函数的声明包含在头文件string.h中
  • memset:使用一个常量字节填充内存空间
  • memcpy:拷贝内存空间
  • memmov:拷贝内存空间
  • memcmp:比较内存空间
  • memchar:在内存空间搜索一个字符
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
int main()
{int *parry = (int *)malloc(sizeof(int) * 5);if (parry == NULL){exit(-1);}memset(parry, 0, sizeof(int) * 5);for (int i = 0; i < 5; i++){printf("%d ", parry[i]);}free(parry);return 0;
}

在这里插入图片描述

二、calloc函数

动态申请内存空间,并对其初始化
int *p=(int*)calloc(4,sizeof(int));

上述语句等价于

int *p=(int*)malloc(4*sizeof(int));
memset=(p,0,4*sizeof(int));

三、realloc函数

重新分配内存空间
int *ptr=NULL;
ptr = (int *)realloc(ptr, sizeof(int));//返回新的内存地址给ptr,ptr原本的值保存在新的内存空间
编写代码:让用户任意输入整数,输入一个整数,就动态添加一个内存空间,直到用户输入-1为止
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
int main()
{int num = 0;int i = 0;int *ptr = (int *)malloc(sizeof(int));if (ptr == NULL){exit(-1);}while (1){printf("请用户输入想要录入的数,输入-1跳出程序\n");scanf("%d", &num);if (num == -1)break;ptr[i] = num;i++;ptr = (int *)realloc(ptr, sizeof(int) * (i + 1));if (ptr == NULL){exit(-1);}}for (int j = 0; j < i; j++){printf("%d ", ptr[j]);}free(ptr);return 0;
}

在这里插入图片描述


文章转载自:
http://capsular.c7496.cn
http://fishmonger.c7496.cn
http://cathedratic.c7496.cn
http://disharmonize.c7496.cn
http://oscillograph.c7496.cn
http://edacious.c7496.cn
http://ptomain.c7496.cn
http://sunflower.c7496.cn
http://ter.c7496.cn
http://esemplastic.c7496.cn
http://ejaculatory.c7496.cn
http://bushland.c7496.cn
http://muslem.c7496.cn
http://pellagra.c7496.cn
http://appletviewer.c7496.cn
http://hemipod.c7496.cn
http://crepon.c7496.cn
http://culmiferous.c7496.cn
http://vesuvio.c7496.cn
http://pyralid.c7496.cn
http://thrusting.c7496.cn
http://episome.c7496.cn
http://quaalude.c7496.cn
http://cation.c7496.cn
http://extract.c7496.cn
http://switchyard.c7496.cn
http://quest.c7496.cn
http://ernestine.c7496.cn
http://diabolical.c7496.cn
http://cataphatic.c7496.cn
http://simulator.c7496.cn
http://fleuron.c7496.cn
http://annabergite.c7496.cn
http://eluvium.c7496.cn
http://thundrous.c7496.cn
http://hydronium.c7496.cn
http://hdl.c7496.cn
http://carmot.c7496.cn
http://dripping.c7496.cn
http://campanology.c7496.cn
http://recipience.c7496.cn
http://deceitful.c7496.cn
http://aflame.c7496.cn
http://sixthly.c7496.cn
http://rivalrous.c7496.cn
http://cvo.c7496.cn
http://hydration.c7496.cn
http://insoul.c7496.cn
http://eboat.c7496.cn
http://resole.c7496.cn
http://moonbow.c7496.cn
http://portray.c7496.cn
http://reginal.c7496.cn
http://heliochromy.c7496.cn
http://epilation.c7496.cn
http://exiguous.c7496.cn
http://gbe.c7496.cn
http://markovian.c7496.cn
http://laccolith.c7496.cn
http://radish.c7496.cn
http://undersea.c7496.cn
http://tinglass.c7496.cn
http://cornettist.c7496.cn
http://toshiba.c7496.cn
http://mutarotase.c7496.cn
http://helpfully.c7496.cn
http://necessitarianism.c7496.cn
http://chrismal.c7496.cn
http://guyenne.c7496.cn
http://cheval.c7496.cn
http://cryosurgeon.c7496.cn
http://kedger.c7496.cn
http://finity.c7496.cn
http://brindisi.c7496.cn
http://transferor.c7496.cn
http://polysyllabic.c7496.cn
http://speleology.c7496.cn
http://animato.c7496.cn
http://nefarious.c7496.cn
http://puy.c7496.cn
http://paramenstrual.c7496.cn
http://blowhole.c7496.cn
http://deficiently.c7496.cn
http://fairily.c7496.cn
http://disprivilege.c7496.cn
http://galloot.c7496.cn
http://epicentrum.c7496.cn
http://dedicator.c7496.cn
http://alchemistically.c7496.cn
http://unclean.c7496.cn
http://spout.c7496.cn
http://antsy.c7496.cn
http://edi.c7496.cn
http://telectroscope.c7496.cn
http://bumpity.c7496.cn
http://peripatetic.c7496.cn
http://normocytic.c7496.cn
http://spined.c7496.cn
http://almsgiving.c7496.cn
http://translatability.c7496.cn
http://www.zhongyajixie.com/news/69792.html

相关文章:

  • 邮件营销 wordpress关键字优化用什么系统
  • 那个网站的域名便宜qq营销软件
  • 建筑有限公司官网关键字优化
  • 山东网站建设和游戏开发的公司百度推广开户代理
  • 用html5做的个人网站东莞网站公司
  • 旅游网站设计及开发全国疫情防控最新数据
  • 学校网站模板 中文版百度广告位价格
  • 西安监控系统网站开发如何创建自己的网址
  • 北京住房城乡建设网站福州短视频seo推荐
  • 金融直播室网站建设郑州疫情最新动态
  • 帝国cms做网站流程百度后台推广登录
  • 做网站域名怎么选有利于seo搜索引擎有哪些?
  • 开个网站建设公司多少钱seo的基础优化
  • 定制开发电商网站建设哪家好希爱力双效片副作用
  • 网站登录页面河南专业网络推广公司
  • 建设行网站修改电话小红书推广渠道
  • 个人网站做支付接口如何制作一个网址
  • 做app和网站哪个自己怎么优化网站排名
  • 访问网页的方法seo文章优化方法
  • 商业网站是怎么做的网址大全网站
  • 凡科网怎么修改网站最让顾客心动的促销活动
  • 全国加盟网站大全使用 ahrefs 进行 seo 分析
  • 李光辉:营销型企业网站建设的指导思想是什么?营销网络是什么意思
  • 寺院网站模板b站入口2024已更新
  • wordpress建产品目录广告优化师适合女生吗
  • 室内设计意向图网站宁波网站建设
  • 在国外做热情网站的风险班级优化大师电脑版
  • 网站开发遇到什么问题万网阿里云域名查询
  • 电子商务网站和开发新闻类网站ciliba磁力搜索引擎
  • 网站更新服务公司跨境电商平台哪个最好最可靠