[問題] 關於結構指標陣列的使用...

看板C_and_CPP作者 (ya)時間14年前 (2011/05/07 20:02), 編輯推噓0(009)
留言9則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) C 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 想問一下26行跟27行為什麼會錯 餵入的資料(Input): 預期的正確結果(Expected Output): 結構指標陣列為什麼不能用指標運算? [36m錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) http://codepad.org/5HWxGaMt 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.13.168

05/07 20:29, , 1F

05/07 20:39, , 2F
優先權問題吧@@
05/07 20:39, 2F

05/07 22:24, , 3F
你是想要用.來存取嗎!? 如果是的話,
05/07 22:24, 3F

05/07 22:24, , 4F
26 printf("Name :%s \t", (*s2[i]).name);
05/07 22:24, 4F

05/07 22:24, , 5F
27 printf("Grade:%d \n", (*s2[i]).score);
05/07 22:24, 5F

05/09 14:02, , 6F
printf("Name :%s \t", (*(s2+i))->name);
05/09 14:02, 6F

05/09 14:03, , 7F
printf("Grade:%d \n", (*(s2+i))->score);
05/09 14:03, 7F

05/09 14:09, , 8F
to glennchen 因為你是指標去對陣列,所以不用做23~26
05/09 14:09, 8F

05/09 14:09, , 9F
的動作
05/09 14:09, 9F
文章代碼(AID): #1DnJJI_k (C_and_CPP)