0
4

1 回答 1

1

list1 and list2 are of type struct file_descriptor ** not struct file_descriptor *.

Further, don't declare a struct file_descriptor pointer or variable inside a loop.

Anyways,if you want the pointers in list2 to point to the same structure variables as the respective pointers in list1 do,then it's fairly simple.You do it as:

 for(i=0;i<=4096;i++)
 list2[i]=list1[i];

Further, if you intend your arrays to be arrays of pointers to the the structure variables, instead of arrays of structure variables, then you should use the following:

   malloc(4096 * sizeof(struct file_descriptor*));  //note the second *

Edit Your line list2[i] = parent_fd; shows type mismatch because you have declared list2 as of type struct file_descriptor* and hence list2[i] is of type struct file_descriptor, while parent_fd is of type struct file_descriptor*.In simple words,the left side of the = is a struct variable while the right side is a pointer to a struct variable. Like I said, you should declare list1 and list2 as type struct file_descriptor** not struct file_descriptor*.That should deal with the warning you encountered.

于 2013-05-05T03:37:12.697 回答