指向结构中指针的指针

时间:2013-01-14 08:50:38

标签: pointers struct

我有一个结构,在里面我有指针(每个都指向一个char数组)。如何创建指向结构内部指针之一的指针?

1 个答案:

答案 0 :(得分:0)

假设C:

struct foo {                // a struct
  char (*a)[10], (*b)[10];  // pointers to arrays[10] of char
};

struct foo x;               // create an object
char (**p)[10];             // pointer to pointer to array[10] of char
p = &x.a;                   // point to one of the pointers inside the struct