672
pointers are very eleganto
(lemmy.world)
Post funny things about programming here! (Or just rant about your favourite programming language.)
char**
So that you can have an array of strings. It's useful to remember that in C arrays and pointers are exactly the same thing, just syntax sugar for however you want to look at it. There are a few exceptions where this isn't true however:
&
operatorsizeof
alignof
which decay is a no-nochar[]
or wide literal ofwchar_t[]
, so likechar str[] = "yo mama";
But
int**
is just an array ofint*
, which likewiseint*
can just be an array ofint
. In the picture here, we haveint** anya
that is an array ofint*
with a size of 1,int* anya
that is an array ofint
with a size of 1, and then of course ourint
there being pointed to byint* anya
.