我基本上試圖創建一個結構指針數組。這些指針中的每一個都應該指向同一結構數組的另一個元素,即BLOCKS [2]。結構指針數組
這是我迄今爲止所做的。
typedef struct bb {
..
..
..
struct bb **successor;
} BLOCK;
BLOCK BLOCKS[10];
struct bb **A = malloc(sizeof(struct bb*)*5); //create an array of pointers of type struct bb, 5 units i.e A[0]->A[4].
BLOCKS[0].successors = A //just assigning
現在......我該如何將指針數組A的第一個元素賦值給另一個結構?
我想:
A[0] = &BLOCKS[6];
它編譯罰款,但我得到了賽格故障。
您是否嘗試過在調試器中運行程序? –
它在哪裏發生故障? – hmjd
它在「A [0] =&BLOCKS [6];」處發生故障。 – maxflow