Search Results

Search found 2 results on 1 pages for 'clear2k'.

Page 1/1 | 1 

  • 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); }

    Read the article

  • passing different structs to a function in c

    - by clear2k
    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 for(i=0; i<size_of_original_content_list; i++){ //fill out passed structure } return the_struct; } int main(int argc, char *argv[]) { return_struct1 = some_func(stu1); return_struct2 = some_func(stu2); // do something separate with each return struct... } Any comments will be appreciate it.

    Read the article

1