看板 Programming 關於我們 聯絡資訊
google了很久找不到,只好上來請教各位老師 我用的語法是C, 在gcc底下compiler 目的是想要create一個string array, 但是google到的都是一維string array... 我想要的data長得像是這樣 #define RAW 3 #define COL 4 #define MAX_LENGTH 10 typedef struct{ char *data[RAW][COL][MAX_LENGTH] = { {"00","David","Taipei", "0912345678"}, {"01","Tommy","Tainan", "0912345678"}, {"02","Elsa","KaoHsiung", "0912345678"} }; }mydatabase_t; int main() { mydatabase_t *mydb; for(int i=0;i<=2;i++) { for(int j=0;j<=4;j++) { printf(" %s ",*mydb->data[i][j]); } printf("\n"); } return 0; } 但是gcc一直跟我說 error: expected ':', ',', ';', '}' or '__attribute__' before '=' token 請問該怎麼宣告和給予初始值以及存取呢呢?先謝謝了 -- ~meow Butter Yuki Cat meow~ △ △ ╭ ╦╗ ═ ╭╬╗ ═╦═ ╦ ╬═╬ ╠╣ ╬═╬ ▲ ▲ =▏ ̄▕= ╬╬║║ ║║║ ║ ║ ╠═╣ ╠╬╗╭╦╗ =███= \_/ ║║║╩╗ ═ ╠╬╣ ═╬═ ╬ ╠═╣ ╭═╣╠╬╣ ◥█◤ ζ∕ ﹨ ╚╬║ ║ ║║║║ ║╮ ║ ╩═╩ ╭═╣║║║ █▋▋ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.158.249 ※ 文章網址: https://www.ptt.cc/bbs/Programming/M.1449131772.A.769.html ※ 編輯: freeedward (125.227.158.249), 12/03/2015 16:37:04 ※ 編輯: freeedward (125.227.158.249), 12/03/2015 16:37:38
bibo9901: 很遺憾…無法這樣 140.112.31.65 12/03 16:42
bibo9901: 沒辦法在定義struct時給初始值, 只能在 140.112.31.65 12/03 16:43
bibo9901: 定義變數時給初始值 140.112.31.65 12/03 16:43
freeedward: 了解了 謝謝125.227.158.249 12/04 10:25