What does this pointer to pointer in the structure mean?

So, I was given the structure:

struct Xxx { struct Yyy{...}; Yyy **yyys; // matrix of yyys }; 

Am I confused by how a pointer to a pointer relates to a matrix?

And how can I initialize a new Yyy and a new Xxx ?

+6
source share
1 answer

The first level pointer will point to an array of pointers, and each second level pointer will point to a Yyy array.

They can be configured as follows:

 struct Yyy **makeMatrix(int rows, int cols) { int i; struct Yyy **result = malloc(rows*sizeof(struct Yyy *)); for (i = 0; i < rows; i++) { result[i] = malloc(cols*sizeof(struct Yyy)); } return result; } 
+3
source

All Articles