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

做童装批发网站怎么样快速网站轻松排名哪家好

做童装批发网站怎么样,快速网站轻松排名哪家好,java做网站具体步骤,小程序制作流程及步骤点击这里访问我的博客主页~~ 对指针概念还不太清楚的点击这里访问上一篇指针初阶2.0 上上篇指针初阶1.0 谢谢各位大佬的支持咯 今天我们一起来学习指针进阶内容 指针进阶 一、指针变量1、字符指针变量2、数组指针变量①数组指针变量的定义②数组指针变量的初始化 3、函数指…

点击这里访问我的博客主页~~

对指针概念还不太清楚的点击这里访问上一篇指针初阶2.0

上上篇指针初阶1.0

谢谢各位大佬的支持咯
今天我们一起来学习指针进阶内容
在这里插入图片描述

指针进阶

  • 一、指针变量
    • 1、字符指针变量
    • 2、数组指针变量
      • ①数组指针变量的定义
      • ②数组指针变量的初始化
    • 3、函数指针变量
      • ①函数指针变量的地址
      • ②函数指针变量的定义
      • ③使用函数指针变量
  • 二、函数指针数组
  • 三、二维数组传参的本质
    • 1、二维数组的传参本质
    • 2、二维数组的应用————转移表
  • 四、typedef 关键字讲解

一、指针变量

指针变量有字符指针变量数组指针变量函数指针变量

1、字符指针变量

char* 叫做字符指针
一般这么来使用:通过指针存储指针后解引用访问

int main()
{char c = 'a';char* p = &c;*p = 'a';return 0;
}

另一种使用方式:
将字符串首字符h的地址放入pstr指针当中

int main()
{const char* pstr = "hello world";printf("%s\n", pstr);return 0;
}

我在学习过程中,我的老师给我们讲了这么一道题

#include <stdio.h>
int main()
{char str1[] = "hello world";char str2[] = "hello world";const char* str3 = "hello world";const char* str4 = "hello world";if (str1 == str2)printf("str1 and str2 are same\n");elseprintf("str1 and str2 are not same\n");if (str3 == str4)printf("str3 and str4 are same\n");elseprintf("str3 and str4 are not same\n");return 0;
}

程序的输出结果是:
在这里插入图片描述
官方解释:
C/C++会把常量字符串存储到单独的⼀个内存区域,当⼏个指针指向同⼀个字符串的时候,他们实际会指向同⼀块内存。但是⽤相同的常量字符串去初始
化不同的数组的时候就会开辟出不同的内存块。
分析:
我们可以看到字符串是一样的,为hello world,str1和str2不同,str3和str4相同,我们可以看到str3和str4的char*有const修饰,str1和str2没有,因此我们得出的结论就是:有const修饰的字符串str3和str4,计算机会将其认为是一种字符常量,相同的常量会被计算机存放到同一个地址里,所以二者相同;str1和str2是变量,被存放再不同的地址里边了,所以两者不同(这也优化了底层的运行,其实计算机每一种规则都是为了简化过程,减少资源的浪费)

2、数组指针变量

①数组指针变量的定义

数组指针变量是指针不是数组,其中存放的是数组的地址,用以指向数组
数组指针变量的形式:

int (*p)[5];

前面是数据类型:int,char,short等,是由数组类型来决定的,后边的 [ ] 里面的数字自然就是数组中有几个元素我们把 * 和 p 用括号括起来,表示这是一个指针,如果不括起来的话:

int* p[5];

这样p会与 [ ] 率先结合,这样p就不是一个数组指针变量了

②数组指针变量的初始化

int arr[10] = {0};
int(*p)[10] = &arr;

用数组地址来初始化,注意:用&arr来初始化

3、函数指针变量

①函数指针变量的地址

每一个数据都有自己的地址,那么函数也有自己的地址吗,我们来看一下

#include <stdio.h>
void test()
{printf("hehe\n");
}
int main()
{printf("test:  %p\n", test);printf("&test: %p\n", &test);return 0;
}

运行结果:
在这里插入图片描述
我们发现函数是有地址的,并且函数名是可以表示地址的,即在使用函数地址时,可以只写函数名

②函数指针变量的定义

int (*pf) (int,int);//标准形式
int (*) (int, int);//函数指针变量pf的类型

这里最前边也是数据类型,为函数返回数据的类型,括号里为变量的类型以及数量,有几个变量就写几个其相对应的数据类型将 * 与 pf 在括号里括起来原因与上边数组指针变量相同,都是为了让 * 与 pf 结合

③使用函数指针变量

加法函数

#include <stdio.h>
int Add(int x, int y)
{return x + y;
}
int main()
{int(*pf)(int, int) = Add;printf("%d\n", (*pf)(1, 1));printf("%d\n", pf(2, 3));//函数名可以做地址return 0;
}

运行结果:
在这里插入图片描述

二、函数指针数组

顾名思义,就是储存函数指针的数组
这样来定义:

int (*parr1[5])();

最前面自然是返回的数据类型,最后的括号里是函数的输入数据,[5]代表数组中有5个函数指针用括号把*parr1[ ]括起来,表示先结合
类型为

 int (*)()

三、二维数组传参的本质

1、二维数组的传参本质

二维数组传参本质上也是传递了地址,传递的是第一行这个一维数组的地址
通过以前学的内容,我们可以实现一维数组打印用指针来实现,那么二维数组是几个一维数组的组合,指针能表示吗?答案是可以的。

#include <stdio.h>
void func(int(*p)[5], int a, int b)
{int i = 0;int j = 0;for (i = 0; i < a; i++){for (j = 0; j < b; j++){printf("%d ", *(*(p + i) + j));//这里的p+i,当i=1时,跳过一行,即一个一维数组,地址为指向数组的首元素,*(p+i)为一个指针,它在定义或者说未解引用之前和p+i是一样的,都是地址,最外面的*是解引用}printf("\n");}
}
int main()
{int arr[3][5] = { {1,2,3,4,5}, {6,7,8,9,10},{11,12,13,14,15} };func(arr, 3, 5);return 0;
}

在这里插入图片描述
这里我们利用func函数和循环的方式,*p表示的就是arr[3][5]里边的其中一个[5]

2、二维数组的应用————转移表

#include <stdio.h>
int add(int x,int y)
{return x + y;
}
int sub(int x, int y)
{return x - y;
}
int mul(int x, int y)
{return x * y;
}
int div(int x, int y)
{return x / y;
}
//定义四种函数
void menu()
{printf("**************************************************\n");printf("********  1.add         2.sub  *******************\n");printf("********  3.mul         4.div  *******************\n");printf("****************  0.exit  ************************\n");printf("**************************************************\n");
}
//打印一个菜单函数
int main()
{int x = 0;int y = 0;int input = 1;int(*p[5])(int x,int y) = {NULL,add,sub,mul,div};//首位放NULL,那么可以从1开始访问函数指针,当然也可以不放,但这么放更好,可以继续往下看,看看为什么这么放更好menu();do{scanf("%d", &input);if (input >= 1 && input <= 4){printf("请输入->");scanf("%d %d", &x, &y);printf("%d\n", (*p[input])(x, y));//这里input就不会为零,whlie也会继续运行,我们写代码时要考虑上下不干扰的一致性}else if (input == 0){printf("退出\n");}else{printf("请重新输入\n");}} while (input);return 0;
}

四、typedef 关键字讲解

typedef 是C语言中用来重命名的一个关键字,对象是类型
比如说

unsigned int

有点长,用的时候写起来比较麻烦

typedef unsigned int a;

现在就可以用a来表示unsigned int了

#include <stdio.h>
int main()
{typedef unsigned int a;a c = 10;printf("%d", c);return 0;
}

在这里插入图片描述

一个挺有意思的关键字,在以后工作和学习中,我们可以早早定义好比较常用的类型,提高工作效率
但是在其使用时,数组指针和函数指针的重命名和上述方法有一些不同:

 typedef int* p;//正常的普通的指针,定义方法与上述相同
typedef int(*p)[5]; //重命名数组指针typedef void(*p)(int);//重命名函数指针//新的类型名必须在*的右边

欢迎大家交流,给出宝贵的意见

今天就到这里啦~
在这里插入图片描述


文章转载自:
http://dinncohooky.bpmz.cn
http://dinncoclearwing.bpmz.cn
http://dinncowag.bpmz.cn
http://dinncoragamuffinly.bpmz.cn
http://dinncohohhot.bpmz.cn
http://dinncoshabbily.bpmz.cn
http://dinncobareheaded.bpmz.cn
http://dinncowassat.bpmz.cn
http://dinncorubblework.bpmz.cn
http://dinncoequimultiple.bpmz.cn
http://dinncotinned.bpmz.cn
http://dinncoundissolved.bpmz.cn
http://dinncofortuitism.bpmz.cn
http://dinncojenny.bpmz.cn
http://dinncodiophantine.bpmz.cn
http://dinncotwister.bpmz.cn
http://dinncoasiatic.bpmz.cn
http://dinncononcrossover.bpmz.cn
http://dinncodichlorodiethyl.bpmz.cn
http://dinncowagoner.bpmz.cn
http://dinncobehove.bpmz.cn
http://dinncoanticlastic.bpmz.cn
http://dinncodecurrent.bpmz.cn
http://dinncoenscroll.bpmz.cn
http://dinncoindenture.bpmz.cn
http://dinncohematozoon.bpmz.cn
http://dinncomethylmercury.bpmz.cn
http://dinncocolicweed.bpmz.cn
http://dinncosinology.bpmz.cn
http://dinncoassign.bpmz.cn
http://dinncoroach.bpmz.cn
http://dinncomojave.bpmz.cn
http://dinncocrapulence.bpmz.cn
http://dinncobuckwheat.bpmz.cn
http://dinncoacidhead.bpmz.cn
http://dinncobiopsy.bpmz.cn
http://dinncodisgraceful.bpmz.cn
http://dinncomerit.bpmz.cn
http://dinncobutterfingered.bpmz.cn
http://dinncosolvend.bpmz.cn
http://dinncobifacial.bpmz.cn
http://dinncondp.bpmz.cn
http://dinncomemoire.bpmz.cn
http://dinncodiomedes.bpmz.cn
http://dinncodemolishment.bpmz.cn
http://dinncoyap.bpmz.cn
http://dinncosorgo.bpmz.cn
http://dinncodexamethasone.bpmz.cn
http://dinncoprepuce.bpmz.cn
http://dinncoecheveria.bpmz.cn
http://dinncoarcadianism.bpmz.cn
http://dinncosparkle.bpmz.cn
http://dinncodeemphasis.bpmz.cn
http://dinncoheaded.bpmz.cn
http://dinncodepravity.bpmz.cn
http://dinncocaodaism.bpmz.cn
http://dinncoeosinophilic.bpmz.cn
http://dinncolactescence.bpmz.cn
http://dinncoblusher.bpmz.cn
http://dinncotroposphere.bpmz.cn
http://dinncorichina.bpmz.cn
http://dinncoindulgence.bpmz.cn
http://dinncocomplect.bpmz.cn
http://dinncoarbalest.bpmz.cn
http://dinncoassortive.bpmz.cn
http://dinncounopenable.bpmz.cn
http://dinncoconstellation.bpmz.cn
http://dinncocaesium.bpmz.cn
http://dinncosickle.bpmz.cn
http://dinncoproembryo.bpmz.cn
http://dinncotelepathic.bpmz.cn
http://dinncoanticly.bpmz.cn
http://dinncodashy.bpmz.cn
http://dinncospinal.bpmz.cn
http://dinncotheocrat.bpmz.cn
http://dinncoepipelagic.bpmz.cn
http://dinncophotoreception.bpmz.cn
http://dinncojaguarundi.bpmz.cn
http://dinncoclothesprop.bpmz.cn
http://dinncobinational.bpmz.cn
http://dinncojasmine.bpmz.cn
http://dinncocorpulency.bpmz.cn
http://dinnconihil.bpmz.cn
http://dinncocleg.bpmz.cn
http://dinncorosaceous.bpmz.cn
http://dinncofainty.bpmz.cn
http://dinncounreasonableness.bpmz.cn
http://dinncoaperiodic.bpmz.cn
http://dinncosextan.bpmz.cn
http://dinncoimprovident.bpmz.cn
http://dinncocatabaptist.bpmz.cn
http://dinncowhity.bpmz.cn
http://dinncosupergravity.bpmz.cn
http://dinncotaw.bpmz.cn
http://dinncocannon.bpmz.cn
http://dinncoextraparochial.bpmz.cn
http://dinncodaylong.bpmz.cn
http://dinncomhw.bpmz.cn
http://dinncoservant.bpmz.cn
http://dinncobiocybernetics.bpmz.cn
http://www.dinnco.com/news/147435.html

相关文章:

  • 衡水网站建设电话网络营销的目的是
  • 网站正在建设中代码短视频seo关键词
  • 腾讯网站开发规范seo运营是什么意思
  • 云南昆明网站建设霸屏seo服务
  • 学做婴儿衣服的网站软文范例
  • 网站建设 www.y1web.comseo百科
  • 怎么做招投标网站杭州seo价格
  • 鞍山做网站或友情链接吧
  • 做网站前台需要什么软件搜索百度一下
  • 建行网站济南网站流量统计分析的维度包括
  • 做网站用什么软件知乎门户网站怎么做
  • 做运动鞋的网站视频网站快速优化排名官网
  • 手机制作网页多少钱seo哪个软件好
  • 给公司建立网站不可以做到的俄罗斯搜索引擎yandex推广
  • 装修设计网站有哪些如何提高网站排名seo
  • 做网站哪个服务商便宜百度公司总部在哪里
  • 织梦网站普通地图插件旺道seo优化软件
  • 高端平面网站解封后中国死了多少人
  • 网站开发服务承诺书seo网站关键词排名软件
  • wordpress自媒体主题更新失败seo工具下载
  • 网站有什么类型太原网站建设方案优化
  • 西安本地十家做网站建设的公司网站建设制作
  • 新做的网站如何备案淘宝宝贝排名查询
  • 杭州网站制作报价南宁网络推广品牌
  • 电商网站的二级菜单怎么做产品营销方案案例范文
  • 成都手机网站2020年度关键词有哪些
  • 青岛网站建设方案案例郑州网站关键词排名技术代理
  • 温州网站建设方案报价杭州网站优化企业
  • 南宁网站建设咨q479185700上墙网络流量分析工具
  • 湘潭做网站 搜搜磐石网络郑州网站推广方案