0

I have a struct which has an array of another struct inside its.

typedef struct info_single {
    pid_t pidx;
    int type;
} info_single;

struct shared_info {
    long indexx;
    struct info_single single_info[];
};

The size of the array is given by the user. How do I allocate the memory through a malloc? This is my solution but i don't know if it is correct

struct shared_info * data;
data = malloc(sizeof(*data)+n*sizeof(info_single));

0 Answers0