c***k 发帖数: 1589 | 1 想在struct a里定义一个dynamic array of pointers,每个pointer都指向另一个
struct b
typedef struct {
b **p
} a;
typedef struct {
int i;
} b;
那么我以后能不能用这个格式来访问
a *ptr;
ptr->p[3]->i; |
l*****d 发帖数: 754 | 2 I think it is ok, except that the definition of b should appear before the d
efinition of a in this case.
【在 c***k 的大作中提到】 : 想在struct a里定义一个dynamic array of pointers,每个pointer都指向另一个 : struct b : typedef struct { : b **p : } a; : typedef struct { : int i; : } b; : 那么我以后能不能用这个格式来访问 : a *ptr;
|
c***k 发帖数: 1589 | 3 But I got the compile time error :(
"dereferencing pointer to incomplete type"
d
【在 l*****d 的大作中提到】 : I think it is ok, except that the definition of b should appear before the d : efinition of a in this case.
|
l*****d 发帖数: 754 | 4 Have you moved definition b in front of that of a?
Also have you allocated memory for array p[]?
【在 c***k 的大作中提到】 : But I got the compile time error :( : "dereferencing pointer to incomplete type" : : d
|
c***k 发帖数: 1589 | 5 I forgot to cast, thank you ^^
【在 l*****d 的大作中提到】 : Have you moved definition b in front of that of a? : Also have you allocated memory for array p[]?
|