指向字符混淆的指针
pointer to char confusion
我正在复习《c++编程语言》一书中的一些主题。在指针的章节中,Stroustrup有以下例子:
int* pi; // pointer to int
char* ppc; // pointer to pointer to char
int* ap[15]; // array of 15 pointers to ints
int (*fp)(char*); // pointer to function taking a char* argument; returns an int
int* f(char*); // function taking a char* argument; returns a pointer to int
char* ppc; // this char has only one *, how can this a pointer to pointer to char?
这是书中的错误还是完全正确?
而不是
char* ppc; // pointer to pointer to char
应该是
char** ppc; // pointer to pointer to char
应该是char** ppc;
你在读哪一版?在我的[The.C++.Programing.Language.Special.Edition]中如下:
int* pi; // pointer to int
char** ppc; // pointer to pointer to char
int* ap[15]; // array of 15 pointers to ints
int (*fp) (char *); // pointer to function taking a char* argument; returns an int
int* f(char *); // function taking a char* argument; returns a pointer to int
这一定是书中的打印错误。
您应该有**
来获取指向指针的指针
相关文章:
- 指向指向字符数组的指针数组的指针
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 将字符缓冲区强制转换为函数指针
- 在函数中返回无符号字符数组,但不返回指针
- 将字符逐个分配给指针?
- 如何返回实际值(在我的例子中是无符号字符数组)而不是来自 C++ 函数的指针?
- 如何循环访问 cpp 中的函数返回的字符指针数组
- 将字符数组复制到 QByte 数组中,而无需传递指针
- C++:使用没有位移位的指针将无符号字符转换为无符号 int
- C++指针数组到字符数组中的特定位置
- 如何从链表指针字符中查找字符
- 获取字符数组地址,然后转换为指针字符
- 在指针字符 c++ 中分配字符数组的值
- C 指针字符
- 将向量传递<char>到指针字符*
- 如何修复未对齐的指针(字符**)
- 如何打印指针字符数组
- 指针 *字符和 &字符
- C++指针字符
- C/ c++:从指针字符一维数组中访问单个字符