I would like to do something like:
struct mystruct {
char *info;
};
// here is where I'm not sure how to
void do_something(struct mystruct **struc){
int i;
for (i = 0; i < 10; i++){
*struc[i] = (struct mystruct *) malloc (sizeof (struct mystruct));
*struc[i]->info = "foo";
}
}
int main(int argc, char *argv[]){
struct mystruct **struc;
struc = (struct mystruct **struc) malloc (sizeof(struct mystruct *struc) * 10);
dosomething(&struc);
// do something with struc and its new inserted values
return 0;
}
I'm not sure how to pass it as a reference so I can make use of it after dosomething()
Thanks
struct mystruct ***into a function that takes astruct mystruct **. That aside, what's the problem? All the values should be accessible to you after the function returns.void do_something(struct mystruct **struc)should take***strucas its argument, I think.