使用指针到指针时出错
Error when use Pointer-to-Pointer
我正在使用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 个 ** 才能定义指向指针的指针(* 到 *)
相关文章:
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 将链表转换为指针数组时出错
- 尝试将指针与结构一起使用时出错
- 将类指针类型转换为键时出错
- 如果我在指针中使用 ++ 操作数,我的值就会出错
- 在 Clang 中使用指向成员的指针时出错
- 编译包含指向模板函数的指针的初始值设定项列表时,gcc 出错,但 clang 不出错
- 通过在迭代指针键映射上出错来捕获非确定性
- 调用指向成员函数的指针时出错
- 通过具有矢量基址的指针读取矢量元素时出错
- 尝试返回指向 Visual Studio 中的动态数组的指针时出错C++
- 将空间分配给整数指针时出错
- GNU 链接器:如果头文件中的指针被声明为 NULL 和/或 extern,则出错
- 尝试将结构指针传递给类时出错
- 我设计了一个类并创建了基指针,但是当我尝试通过基指针访问派生函数时,它会出错
- 非标准语法;使用 '&' 创建指向成员的指针错误,将成员函数分配给向量时出错
- 指向 2D 数组的指针出错
- 删除vector中的指针出错
- 在c++函数中使用指针出错
- 指向数组参数的双指针出错