Hello I have a problem with one function. The Declaration is:
int load_clusters(char *filename, struct cluster_t **arr)
And i dont know how to work with these 2 pointers before **arr. I expect that i call it like this:
struct cluster_t *clusters;
load_clusters("file.txt",&clusters);
But I'm not sure if it is correct or not.
In the function I need to alocate memory for it. I think it have to be like this.
arr = (struct cluster_t**)malloc(count * sizeof(struct cluster_t*));
arr[0...x] = (struct cluster_t*)malloc(sizeof(struct cluster_t));
arr[0...x]->size += 1;
.
.
.
But after all this I need to call function to print clusters.
void print_clusters(struct cluster_t *carr, int narr)
{
printf("Clusters:\n");
for (int i = 0; i < narr; i++)
{
printf("cluster %d: ", i);
print_cluster(&carr[i]); AND THIS DOESN'T WORK AS I EXPECT
}
}
Thank for all help ;-)