Reputation: 2992
I'm reviewing some topics in the book "The c++ programming language". In the chapter in pointers, Stroustrup have these examples:
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?
Is this an error in the book or this is entirely correct?
Upvotes: 0
Views: 66
Reputation: 5712
It must be a printing mistake in the book.
You should have **
to get the pointer to a pointer
Upvotes: 0
Reputation: 172894
It should be char** ppc;
Which edition are you reading? It's as follows in my [The.C++.Programming.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
Upvotes: 0
Reputation: 32576
Instead of
char* ppc; // pointer to pointer to char
it should be
char** ppc; // pointer to pointer to char
Upvotes: 3