I was given this piece of example code on a lab and I'm trying to understand it
int size = 5;
int **ppi2 = (int **) malloc(size * sizeof(int *));
Here's my breakdown of it as of now:
In order to allocate sufficient memory, we must multiply the number of things we want to allocate memory for (size) by the size of those things (sizeof(int *)). That much is straightforward and makes a lot of sense.
I understand that we have to cast the result of malloc into a double pointer, since malloc returns bytes and the variable is a double pointer, but why are we setting ppi2 equal to the result of malloc in the first place? Does it make ppi2 point to the spot in memory that we just allocated?