[問題] 怎麼解決左元運算值必須為左值(c語言結構)???

看板C_and_CPP (C/C++)作者時間16年前 (2010/03/23 13:11), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 ) ( 未必需要依照此格式,文章條理清楚即可 ) 以下為程式碼 struct Food { char name[50]; double carbohydrate, protein, fat, other,kcal; char fruit; }; struct Food2 { char name[50],name2[50]; double carbohydrate, protein, fat, other,kcal,g[50]; char foodla[50][50]; int foodCount; }; 主函式 struct Food a[10]; struct Food2 temp; temp.foodla[temp.foodCount]=a[0].name; 為什麼沒辦法把a結構裡的第0項食物名稱 複製到temp結構裡??? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.72.84.170

03/23 13:15, , 1F
strcpy(temp.foodla[temp.foodCount],a[0].name);
03/23 13:15, 1F

03/23 13:18, , 2F
原來要用到strcpy..... 我知道了 謝謝你^^
03/23 13:18, 2F
文章代碼(AID): #1Bg4s2WP (C_and_CPP)
文章代碼(AID): #1Bg4s2WP (C_and_CPP)