c struct pointer issues
- by clear2k
I'm trying to cast a struct into another struct but I'm having incompatible pointer issues within the cast and the malloc under some_func (structs layout are the same)
struct stu1 **some_func(struct stu1 *my_struct)
{
my_struct = (struct stu1 **)malloc(sizeof(struct stu1 *)*total_size);
for(i=0;i<20;i++){
my_struct[i] = (struct stu1 *)malloc(sizeof(struct stu1));
printf("%s",my_struct[i++]->a);
}
}
int main()
{
struct stu1 **my_struct;
struct stu2 **my_struct2;
struct stu3 **my_struct3;
my_struct = some_func(my_struct);
my_struct2 = (struct stu2**)some_func((struct stu1*)my_struct2);
my_struct3 = (struct stu3**)some_func((struct stu1*)my_struct3);
}