相关疑难解决方法(0)

const导致不兼容的指针类型.为什么只有双指针?

这个问题已在这里得到解决.

建议的副本和当前给出的答案没有解决为什么首先给出的示例没有问题.主要是为什么没有推理:

" const int ** is a pointer to const int * 这与其他事情不同int*"

也适用于:

" const int * is a pointer to const int 这与其他事情不同int"


我从不同的角度接近它,希望得到另一种解释.

带有示例的代码.

#include <stdio.h>

void f_a (int const a){

    /*
     *  Can't do:
     *      a = 3;  //error: assignment of read-only parameter ‘a’
     *
     * Explanation: I can't change the value of a in the scope of the function due to the const
    */
    printf("%d\n", a); …
Run Code Online (Sandbox Code Playgroud)

c pointers const

8
推荐指数
2
解决办法
1270
查看次数

标签 统计

c ×1

const ×1

pointers ×1