#include <stdio.h>
int main()
{
int i = 11;
int *p = &i;
foo(&p);
printf("%d ", *p);
}
void foo(int *const *p)
{
int j = 10;
*p = &j;
printf("%d ", **p);
}
FOO函数中的参数如何操作,int * const *和int ** const是同一件事?
答案 0 :(得分:0)
这可以帮助您回答:Clockwise/Spiral Rule
然后下面是一些解释const和指针概念的示例:
int* - pointer to int
int const * - pointer to const int
int * const - const pointer to int
int const * const - const pointer to const int
现在第一个const可以位于类型的任意一侧,所以:
const int * == int const *
const int * const == int const * const
如果您想走得更远,可以执行以下操作:
int ** - pointer to pointer to int
int ** const - a const pointer to a pointer to an int //THIS IS YOUR CASE
int * const * - a pointer to a const pointer to an int //THIS IS YOUR CASE
int const ** - a pointer to a pointer to a const int
int * const * const - a const pointer to a const pointer to an int