2013-04-30 51 views
2

我所定義的數據結構如下:陣列中C結構的陣列 - 聲明

struct image{ 
unsigned int width, height; 
unsigned char *data; 
}; 

結構的數組如上所定義會是這樣的:

struct image input[NR_FRAMES]; 

如果我想另一個數組,比如說streams,它具有上述定義的結構數組作爲元素streams[i],我將如何聲明它?

回答

3
typedef struct image Stream[NR_FRAMES]; 
Stream streams[NR_STREAMS]; 

或者乾脆:

struct image streams[NR_STREAMS][NR_FRAMES]