2013-03-17 31 views

回答

1

例如,在一些哈希表(關聯字符串名稱爲整數值)一些桶可能是

struct bucket_st { 
    unsigned len; 
    struct { 
     char* name; 
     int val; 
    } ent[]; 
}; 

我在bucket_st結構使用flexible array memberent,這必須是一個嵌套struct

另外,如果你正在編寫一個2D的應用程序,你可能有很多的

struct point_st { int x, int y; }; 

,你會由兩個極值點定義線段:

struct linesegment_st { 
    struct point_st p0, p1; 
}; 

然後,如果li是這樣一行,你想談談li.p0.x等...

在POSIX或Linux API中,setitimer(2)系統調用struct itimerval其中包含其他struct ....

我真的很驚訝你問過關於嵌套結構。你真的沒有很多。

+0

什麼是Flexible array:/ – 2013-03-17 18:00:18

+0

添加了一個鏈接,它是其實*靈活的陣列成員* – 2013-03-17 18:02:04

+0

爲什麼最近downvote? – 2013-03-17 18:02:57