使用指针到指针时出错

Error when use Pointer-to-Pointer

本文关键字:指针 出错      更新时间:2023-10-16

我正在使用Visual Studio 2013。今天,我对指针做了一些研究,当尝试从 orther 指向指针时,我发现了错误。此行发生错误: 字符 *cPP = &cP;当尝试读取 cP 的地址并戴上 cPP 时。Visual Studio宣布:

a value of type "char **" cannot be used to initialize an entity of type "char *"   

你能解释一下吗?

我该如何修复此错误?

#define   stop __asm nop
int main()
{
    char a = 'A';
    char *cP = &a;
    char *cPP = &cP;
    stop
    return 0;
}
#define   stop __asm nop
int main()
{
    char a = 'A';
    char *cP = &a;
    char **cPP = &cP;
    stop
    return 0;
}

必须有 2 个 ** 才能定义指向指针的指针(* 到 *)