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:
Argument of the & operator
Argument of sizeof
C11 has alignof which decay is a no-no
When it’s a string literal of char[] or wide literal of wchar_t[], so like charstr[] = "yo mama";
But int** is just an array of int*, which likewise int* can just be an array of int. In the picture here, we have int** anya that is an array of int* with a size of 1, int* anya that is an array of int with a size of 1, and then of course our int there being pointed to by int* anya.
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
.