这些指针的含义,指针指针,函数指针和数组指针 [英] meaning of these pointers, pointer-to-pointer, function pointer and array pointer

查看:72
本文介绍了这些指针的含义,指针指针,函数指针和数组指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名大学生,我们的老师让我们说出这些指针的含义,但我只设法弄清楚其中的一些:

I'm a university student, our teacher told us to tell the meaning of these pointers, but I only manage to figure out some of them:

1. int *p1;
2. int *p2[10];
3. int (*p3)[10];
4. int (*p4)();
5. int **p5();
6. int (**p6)[10];
7. int (**p7)();
8. int *(*p8)();
9. int (*p9[10])();
10. int **p10[10];

这是我目前想到的:

  • p1 是一个指向 int 的指针
  • p2 是一个包含 10 个 int 指针的数组
  • p3 是指向具有 10 个元素的静态数组的指针
  • p4 是一个函数指针
  • p5 根本不是指针,而是返回 int** 的函数原型
  • p6 是一个包含 10 个指针的数组
  • p7 是一个指向函数指针的指针

你们能帮帮我吗?因为我们的老师告诉我们这些会在考试中

Can you guys please help me? Because our teacher told us these will be on the exam

推荐答案

cdecl.org 可以使用破译像您的示例这样的杂乱声明:

cdecl.org can be used to decipher messy declarations like your examples:

int (*p9[10])(); => 将 p9 声明为返回 int 的函数指针的数组 10

int (*p9[10])(); => declare p9 as array 10 of pointer to function returning int

如果失败,您可以使用顺时针/螺旋法则来磨练他们手动.

Failing that, you can use Clockwise/Spiral Rule to grind through them manually.

这篇关于这些指针的含义,指针指针,函数指针和数组指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆