I have different structures that need to be filled out the same way. The only difference is that they are filled based on different data.
I was wondering if it's possible to pass different structures to a certain function. What I have in mind is something like:
struct stu1 {
char *a;
int b;
};
struct stu2 {
char *a;
int b;
};
static struct not_sure **some_func(struct not_sure **not_sure_here, original_content_list)
{
// do something and return passed struct
the_struct = (struct not_sure_here **)malloc(sizeof(struct not_sure_here *)20);
for(i=0; i<size_of_original_content_list; i++){
//fill out passed structure
}
return the_struct;
}
int main(int argc, char *argv[])
{
struct stu1 **s1;
struct stu2 **s2;
return_struct1 = some_func(stu1);
return_struct2 = some_func(stu2);
// do something separate with each return struct...
}
Any comments will be appreciate it.