龙空技术网

C语言(十):指向指针的指针

LearningYard学苑 126

前言:

目前姐妹们对“c语言指向指针的指针”大体比较关切,兄弟们都想要剖析一些“c语言指向指针的指针”的相关知识。那么小编也在网摘上搜集了一些关于“c语言指向指针的指针””的相关文章,希望朋友们能喜欢,我们一起来了解一下吧!

分享兴趣,传播快乐,

增长见闻,留下美好!

亲爱的您,这里是LearningYard新学苑。

今天小编为大家带来的是

C语言(十):指向指针的指针。

Share interests, spread happiness,

increase knowledge, and leave behind beauty!

Dear you, this is the Learning Yard New School.

Today's editor brings you

C language (10): Pointer to pointer.

一、思维导图

此推文关于指向指针的指针的内容主要如下:

The main content of this tweet about pointers to pointers is as follows:

二、关于解引用

请看下面一段代码:

Take a look at the following code:

在这里层层解引用最终都可以求得520.

Here, we can solve the problem of 520

num

520

p

&num

*p

num

520

pp

&p

*pp

p

&num

**pp

*p

num

520

第一行表示num中存放的值是520;

第二行表示p中存放的是num的地址;

第三行表示解引用p得到num,最终得到值520;

第四行表示pp中存放p的地址;

第五行表示奖pp解引用一次得到p,p中存放num的地址;

第六行表示将pp解引用两次得到num,进而得到值520;

The first line indicates that the value stored in num is 520;

The second line indicates that the address stored in p is num;

The third line indicates that the reference p is dereferenced to obtain num, and the final value 520 is obtained;

The fourth line indicates the address where p is stored in the pp;

The fifth line represents the address where the num is stored in p, which is obtained by dereference of the award pp once;

The sixth line indicates that the value 520 is obtained by dereferencing pp twice to obtain num;

三、指针数组和指向指针的指针

指针数组:一个数组的元素值为指针则是指针数组。指针数组是一组有序的指针的集合。

指向指针的指针运用的好处:避免重复分配内存;只需要进行一处修改;代码的灵活性和安全性都显著提高

Pointer array: An array whose element value is a pointer is a pointer array. A pointer array is an ordered collection of pointers.

Advantages of using pointers to pointers: avoiding repeated memory allocation; Only one modification is required; Significant improvements in code flexibility and security

四、数组指针和二维数组

如图所示,用指针间接访问一维数组:

As shown in the figure, use a pointer to indirectly access a one-dimensional array:

但是指针不能间接访问二维数组,如图示:

However, pointers cannot indirectly access two-dimensional arrays, as shown in the figure:

主要是因为二维数组是连续存放的,主要解释如图所示:

The main reason is that two-dimensional arrays are stored continuously. The main explanation is shown in the figure:

改进后用指针表示二维数组,如图示:

After improvement, a pointer is used to represent a two-dimensional array, as shown in the figure:

详细解释链接:

Detailed explanation link:

结语:编者认为指针部分比较难懂,所以文章有什么问题还请大家提出来。

Conclusion: The editor thinks that the pointer part is difficult to understand, so if there is any problem in the article, please ask everyone to raise it.

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天,

祝您今天过得开心快乐!

That's all for today's sharing.

If you have unique ideas about today's article,

please leave us a message.

Let's meet tomorrow.

I wish you a happy day!

翻译:百度翻译

参考:《零基础入门学习C语言:带你学C带你飞》、哔哩哔哩小甲鱼视频、网络图片

声明:本文由LearningYard新学苑原创,若有侵权请联系删除

文案&排版:易春秀

审核:闫庆红

标签: #c语言指向指针的指针 #c语言指针指向指针