我如何阅读C指针构造?

前端之家收集整理的这篇文章主要介绍了我如何阅读C指针构造?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是一个新手C问题.以下两个结构有什么区别?
1. const int* const* const x
2. const int**

我如何阅读这些结构?

解决方法

如果你以正确的方式分组,它会变得容易一些.例如,* const实际上是一个单位,意思是“const指向”(你可以在这里读取const作为下标:* const).我把它写成:
const int *const *const p1; // p1 is a const pointer to const pointer to const int
const int **p2; // p2 is a pointer to pointer to const int

还要记住,声明读取“inside out”,从声明的标识符开始.

原文链接:https://www.f2er.com/c/111004.html

猜你在找的C&C++相关文章