Why this is possible:
char buf[10], *pbuf = buf, **ppbuf = &pbuf;
and this isn't:
char buf[10], **ppbuf = &buf;
As I understand, the second line is just a shorthand of the first one.
They're not equivalent.
*pbuf = buf
That means, "pbuf
is a pointer to type char
, whose value is the address of buf
." Since buf
is an array of chars, this works.
**ppbuf = &pbuf
That means, "ppbuf
is a pointer to a pointer to type char
, whose value is the address of pbuf
." Since pbuf
is a pointer to type char
, this works.
**ppbuf = &buf
This means, "ppbuf
is a pointer to a pointer to type char
, whose value is the address of buf
." Since buf
is an array of chars, this fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With