[C]結構內動態陣列大小設初值
參考:
http://stackoverflow.com/questions/1558025/c-initialize-array-within-structure
不是後來才用malloc的那種動態陣列。
typedef struct {
int row;
int col;
char **ar;
}fooStruct;
static const foostruct fooArr[] = {
{2, 10, (char*[2]) { (char[10]) {"hello"}, (char[10]) {"world"} } },
.....
}
這樣宣告的話
fooArr[0].ar[0]就是hello
fooArr[0].ar[1]就是world
0 個意見:
張貼留言
訂閱 張貼留言 [Atom]
<< 首頁