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

做任务赚佣金网站有哪些百度手机卫士

做任务赚佣金网站有哪些,百度手机卫士,如何修改wordpress编辑器,wordpress格行代码指针---进阶篇(三) 一、前言二、一维数组例题透析:三、指针笔试题1.例一:2.例二:3.例三:4.例四:5.例五:6.例六: 一、前言 那么好了好了,宝子们,从…

指针---进阶篇(三)

  • 一、前言
  • 二、一维数组例题透析:
  • 三、指针笔试题
    • 1.例一:
    • 2.例二:
    • 3.例三:
    • 4.例四:
    • 5.例五:
    • 6.例六:

一、前言

那么好了好了,宝子们,从今天开始开始总结暑假博客,从指针开始,后续,来吧开始整活!⛳️

二、一维数组例题透析:

关于数组名的理解:
arr,首先数组名是数组首元素的地址 毋庸置疑
&arr,取地址符号加上数组名取出的是整个数组的地址

但是有2个例外:
1.sizeof后面括号内只有数组名的话,计算的是整个数组的大小单位是字节。
2.&加上数组名,取出的是整个数组的地址

还有一点特别需要注意:

只要是指针也就是地址,它的大小必然是4或8个字节,4/8个字节的原因是在不同的环境下x86和x64。

1.int a[ ] = { 1,2,3,4 };

#include <stdio.h>
int main()
{int a[] = { 1,2,3,4 };printf("%d\n", sizeof(a));//计算的是整个数组的大小:4*4=16printf("%d\n", sizeof(a+0));//sizeof(a+0)得到的是数组首元素的地址:4/8printf("%d\n", sizeof(*a));//a是数组首元素的地址,*(解引用后)便是数组首元素:1,大小为:4printf("%d\n", sizeof(a+1));// Sizeof(a)是数组首元素地址,加1,也就是数组第2个元素的地址,只要是地址,它的大小就是4/8个字节printf("%d\n", sizeof(a[1]));//数组的下标访问,不必多说,直接就是:4printf("%d\n", sizeof(&a));//这里不要被表面现象所迷惑了,&a取出的是整个数组的地址,它本质上还是个地址,所以说只要是地址它的字节大小就是:4/8printf("%d\n", sizeof(*&a));//*和&可以说是抵消了,所以说本质上还是sizeof(a)一样的。计算的是整个数组的大小:4*4=16printf("%d\n", sizeof(&a+1));//&a取的是整个数组的地址加1,也就是跳过了整个数组,本质上他还是个地址,所以说还是4/8个字节printf("%d\n", sizeof(&a[0]));//他取出的是数组首元素的地址,4/8个字节printf("%d\n", sizeof(&a[0]+1));//取出的是数组首元素的地址,然后加1,也就是取出的是数组中第2个元素的地址:4/8个字节return 0;
}

2.char arr[ ] = { ‘a’,‘b’,‘c’,‘d’,‘e’,‘f’};

int main()
{char arr[] = { 'a','b','c','d','e','f'};printf("%d\n", sizeof(arr));//因为sizeof内部的括号只有arr,arr代表整个数组的大小:1*6printf("%d\n", sizeof(arr+0));//4/8printf("%d\n", sizeof(*arr));//这里的arr是数组首元素地址,*后就是数组首元素大小为:1个字节printf("%d\n", sizeof(arr[1]));//1printf("%d\n", sizeof(&arr));//取出的是整个数组的地址,地址的大小只有4/8printf("%d\n", sizeof(&arr+1));//4/8printf("%d\n", sizeof(&arr[0]+1));//4/8//声明:strlen接收的参数类型是(指针):const char * str//strlen函数只有遇到‘\0’为结束标志printf("%d\n", strlen(arr));//随机值因为上面这个数组里面没有'\0',所以strlen要不断的往下遍历,直到遇到'\0'为止。printf("%d\n", strlen(arr + 0));//随机值printf("%d\n", strlen(*arr)); // error,arr是数组首元素的地址, * arr就是数组首元素,就是'a' - 97//strlen函数参数的部分需要传一个地址当我们传递的是"a"时,'a"的ASCII码值是97,那就是将97作为地址传参//strLen就会从97这个地址开始统计字符串长度,这就非法访问内存了printf("%d\n", strlen(arr[1]));//errorprintf("%d\n", strlen(&arr));//随机值printf("%d\n", strlen(&arr+1));//随机值printf("%d\n", strlen(&arr[0]+1));//从第二个元素的地址开始访问,还是随机值

3.char arr[ ] = “abcdef”;

char arr[] = "abcdef";printf("%d\n", sizeof(arr));//因为还有'\0'所以=1*7=7printf("%d\n", sizeof(arr + 0));//首元素的地址:4/8printf("%d\n", sizeof(*arr));//对数组首元素地址*,也就是第1个元素a:1printf("%d\n", sizeof(arr[1]));//1printf("%d\n", sizeof(&arr));//整个数组的地址:4/8printf("%d\n", sizeof(&arr + 1));//4/8printf("%d\n", sizeof(&arr[0] + 1));//4/8printf("%d\n", strlen(arr));//6printf("%d\n", strlen(arr + 0));//6printf("%d\n", strlen(*arr));//errorprintf("%d\n", strlen(arr[1]));//errorprintf("%d\n", strlen(&arr));//整个数组的地址:6printf("%d\n", strlen(&arr + 1));//取出整个数组的地址加1,相当于指针这个数组指向最后一位的后面,随机值printf("%d\n", strlen(&arr[0] + 1));//从b开始,:5个

4.char* p = “abcdef”;

char* p = "abcdef";printf("%d\n", sizeof(p));//4/8  :p是一个指针变量printf("%d\n", sizeof(p+1));//4/8  :p+1是'b'的地址,是地址大小就是4/8个字节 printf("%d\n", sizeof(*p));//1   :就是aprintf("%d\n", sizeof(p[0]));//1    :就是aprintf("%d\n", sizeof(&p));//4/8   :取出的是整个字符串的地址:  char**printf("%d\n", sizeof(&p + 1));//4/8   :char**printf("%d\n", sizeof(&p[0] + 1));//4/8   :&p[0] + 1得到是'b'的地址printf("%d\n", strlen(p));//6printf("%d\n", strlen(p + 1));//   5      printf("%d\n", strlen(*p));//errorprintf("%d\n", strlen(p[0]));//errorprintf("%d\n", strlen(&p));//随机值printf("%d\n", strlen(&p + 1));//随机值printf("%d\n", strlen(&p[0] + 1));//5

5.二维数组:int a[3][4] = { 0 };

	//二维数组int a[3][4] = { 0 };printf("%d\n", sizeof(a));// a是数组名计算的,是整个数组的大小:3*4*4=48;printf("%d\n", sizeof(a[0][0]));//第1行第1个元素的大小:4printf("%d\n", sizeof(a[0]));//这里我们把a[0]看作一个一维数组的数组名:4*4=16printf("%d\n", sizeof(a[0]+1));//a[0]作为第一行的数组名,没有单独放在sizeo内部,没有&//a[0]表示数组首元素的地址,也就是a[0][0]的地址	所以a[0]+1是第一行第二个元素的地址,是地址就是4/8个字节printf("%d\n", sizeof(*a[0]+1));//4  //计算的是就是第一行第2个元素的大小printf("%d\n", sizeof(a+1));// a不是单独放在size of内部就代表数组首元素地址也就是第1行数组的地址,加1,也就是第2行数组的地址:4/8printf("%d\n", sizeof(*(a+1)));//对第2行数组地址*  就是4*4=16printf("%d\n", sizeof(&a[0] + 1));//因为a[0]是第一行数组的数组名,对第1行数组数组名取地址之后再加1,也就是第2行数组的地址:4/8printf("%d\n", sizeof(*(&a[0] + 1)));//对第2行数组地址整个*,4*4=16printf("%d\n", sizeof(*a));//如果a不是单独放在size of内部,那么a就代表数组首元素地址,也就是数组第1行的地址   *后=4*4=16printf("%d\n", sizeof(a[3]));//a[3]代表第三行数组数组名:4*4=16

对二维数组的深度理解:
在这里插入图片描述

三、指针笔试题

1.例一:


int main()
{int a[5] = { 1,2,3,4,5 };int* ptr = (int*)(&a + 1);//取地址加数组名(& a),取出的是整个数组的地址,再+1指向5的后面!!!printf("%d %d", *(a + 1), *(ptr - 1));//a+1:就是数字数元素地址加1,然后*后就是2;//刚开始ptr指的是5的后面,再减1就是指向了5return 0;
}

在这里插入图片描述

2.例二:

这道题主要考察的是:指针类型:决定了指针+1到底加几?

//由于还没学习结构体,这里告知结构体的大小是20个字节
struct Test
{int Num;char* pcName;short sDate;char cha[2];short sBa[4];
}* p = (struct Test*)0x100000;//假设p 的值为0x100000。 如下表表达式的值分别为多少?
//已知,结构体Test类型的变量大小是20个字节
int main()
{printf("%p\n", p + 0x1);//0x100000+1:因为p是一个结构体指针,结构体指针+1跳的是整个结构体,也就是加了20个字节//0x100000+20?错!因为0x100000是16进制的:0x100014printf("%p\n", (unsigned long)p + 0x1);//在这里我们把结构体指针强制类型转化为无符号的数字:+1=0x100001printf("%p\n", (unsigned int*)p + 0x1);//这里我们把结构体指针,p强制类型转化为int*,+1就跳过4个字节:0x100004return 0;
}

在这里插入图片描述
注意前提:环境为X86:
在这里插入图片描述

3.例三:

int main()
{int a[4] = { 1, 2, 3, 4 };int* ptr1 = (int*)(&a + 1);int* ptr2 = (int*)((int)a + 1);printf("%x,%x", ptr1[-1], *ptr2);//ptr1:=4;// a是数组首元素地址,把a数组首元素地址强制转换为int整型,强制转化为int整型之后再+1就是单纯的加数字1了,之后再将这个数字强制转化为int*。//打印的是地址:return 0;
}

在这里插入图片描述

在这里插入图片描述

4.例四:

考察:逗号表达式!

int main()
{int a[3][2] = { (0, 1), (2, 3), (4, 5) };//不要被表面现象所迷惑了,如果012345要存到二维数字中,它每个数组都要用大括号括起来,//而它是用小括号,所以说它是一个逗号表达式,所以说实际上存进去的只有1 3 5这三个数字后面其他的都是0int* p;p = a[0];//a[0]之前不是讲过了吗?是第1行数组的数组名:也就是第1行数组首元素的地址。printf("%d", p[0]);//1return 0;
}

在这里插入图片描述

在这里插入图片描述

5.例五:

int main()
{int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };int* ptr1 = (int*)(&aa + 1);int* ptr2 = (int*)(*(aa + 1));printf("%d,%d", *(ptr1 - 1), *(ptr2 - 1));//1.ptr1:取地址&+数组名aa是取出了整个数组的地址,再加一就是跳过整个二维数组。-1指向了10//2.ptr2:aa是数组首元素地址,在二维数组中,我们把每一行看作一个元素,+1的话就是跳过了第1行,指向了第2行首元素的地址,-1指向了5return 0;
}

在这里插入图片描述

6.例六:

需要画图,才能一目了然!

int main()
{char* c[] = { "ENTER","NEW","POINT","FIRST" };char** cp[] = { c + 3,c + 2,c + 1,c };char*** cpp = cp;printf("%s\n", **++cpp);printf("%s\n", *-- * ++cpp + 3);printf("%s\n", *cpp[-2] + 3);printf("%s\n", cpp[-1][-1] + 1);return 0;
}

在这里插入图片描述

**++cpp步骤一:
在这里插入图片描述

在这里插入图片描述
好了,今天的分享就到这里了

如果对你有帮助,记得点赞👍+关注哦!
我的主页还有其他文章,欢迎学习指点。关注我,让我们一起学习,一起成长吧!

在这里插入图片描述


文章转载自:
http://sameness.xnLj.cn
http://escarp.xnLj.cn
http://palaeoanthropic.xnLj.cn
http://joypopper.xnLj.cn
http://astrography.xnLj.cn
http://consistent.xnLj.cn
http://conversely.xnLj.cn
http://transplantable.xnLj.cn
http://couchette.xnLj.cn
http://homepage.xnLj.cn
http://summarize.xnLj.cn
http://melezitose.xnLj.cn
http://torrent.xnLj.cn
http://opiate.xnLj.cn
http://bloemfontein.xnLj.cn
http://shearling.xnLj.cn
http://decamp.xnLj.cn
http://megalith.xnLj.cn
http://habilitate.xnLj.cn
http://syndactyly.xnLj.cn
http://erectile.xnLj.cn
http://sutlej.xnLj.cn
http://faustus.xnLj.cn
http://limberly.xnLj.cn
http://crescograph.xnLj.cn
http://auctorial.xnLj.cn
http://billionaire.xnLj.cn
http://incubus.xnLj.cn
http://piccanin.xnLj.cn
http://vitrine.xnLj.cn
http://vacuolar.xnLj.cn
http://odeon.xnLj.cn
http://transformist.xnLj.cn
http://liechtensteiner.xnLj.cn
http://exegetical.xnLj.cn
http://blenny.xnLj.cn
http://basle.xnLj.cn
http://paid.xnLj.cn
http://pastorship.xnLj.cn
http://superannuation.xnLj.cn
http://romancist.xnLj.cn
http://tranylcypromine.xnLj.cn
http://indigo.xnLj.cn
http://derisible.xnLj.cn
http://embarrass.xnLj.cn
http://skald.xnLj.cn
http://demarche.xnLj.cn
http://xanthine.xnLj.cn
http://piezometry.xnLj.cn
http://activism.xnLj.cn
http://teenager.xnLj.cn
http://dissaving.xnLj.cn
http://frse.xnLj.cn
http://pterosaur.xnLj.cn
http://draggly.xnLj.cn
http://onliest.xnLj.cn
http://dorado.xnLj.cn
http://nonrigid.xnLj.cn
http://interlineate.xnLj.cn
http://borrow.xnLj.cn
http://osmic.xnLj.cn
http://conglomeratic.xnLj.cn
http://olap.xnLj.cn
http://sandburg.xnLj.cn
http://kcal.xnLj.cn
http://travolater.xnLj.cn
http://orientalist.xnLj.cn
http://oxfly.xnLj.cn
http://shreveport.xnLj.cn
http://eurytopic.xnLj.cn
http://evangelical.xnLj.cn
http://astigmometer.xnLj.cn
http://phrenogastric.xnLj.cn
http://accurst.xnLj.cn
http://towhee.xnLj.cn
http://jiao.xnLj.cn
http://croslet.xnLj.cn
http://squaloid.xnLj.cn
http://survival.xnLj.cn
http://cinchonise.xnLj.cn
http://ensure.xnLj.cn
http://cegb.xnLj.cn
http://veridical.xnLj.cn
http://homoplastic.xnLj.cn
http://soaprock.xnLj.cn
http://benthamism.xnLj.cn
http://petrochemical.xnLj.cn
http://neighborship.xnLj.cn
http://calorimetry.xnLj.cn
http://gauntlet.xnLj.cn
http://southpaw.xnLj.cn
http://place.xnLj.cn
http://demyelination.xnLj.cn
http://camerlingate.xnLj.cn
http://milreis.xnLj.cn
http://structurism.xnLj.cn
http://wantless.xnLj.cn
http://bicoastal.xnLj.cn
http://isthmian.xnLj.cn
http://intenerate.xnLj.cn
http://www.15wanjia.com/news/94926.html

相关文章:

  • 工信部网站备案查询步骤小程序开发一个多少钱啊
  • 隆尧企业做网站百度校招
  • 深圳深度网站建设微软优化大师
  • 互联网 网站建设拉新推广
  • 中国建设厅官方网站平台网站开发公司
  • 网站根目录是哪个文件夹如何进行网站的宣传和推广
  • 河南网络科技网站建设湖南官网网站推广软件
  • 龙华专业做网站头条收录提交入口
  • 企业网站优化外包免费建立个人网站官网
  • 网站建设头部代码在哪买网站链接
  • 蓬莱建网站安装百度到桌面
  • 网站制作需要哪些东西精准营销
  • 如何做简易个人网站google广告
  • 南昌市东站建设公司网络营销渠道的特点
  • 芜湖做网站的邓健照片搜索引擎优化分析报告
  • 公司要搭建网站长沙seo招聘
  • 网站服务器在哪可以看电商培训机构推荐
  • 毕业设计网站题目怎么给网站做优化
  • 带数字 网站 域名郴州网站推广
  • 北京私人做网站优化网站技术
  • 网站上线步骤上海推广外包
  • 21dove谁做的的网站商丘seo公司
  • 软膜做网站有用吗网络事件营销案例
  • 印度网站建设多少钱深圳网站建设
  • 在静安正规的设计公司网站朋友圈广告投放
  • 做网站的服务器cpu异常选择一个产品做营销方案
  • 苏州网站建设工作室游戏推广员是做什么的
  • 花房姑娘直播关键词优化是怎么弄的
  • 成都建网站的公司百度下载免费安装最新版
  • 富阳做网站百度搜索