[問題] C語言函數 傳入與傳回值為結構問題

看板C_and_CPP (C/C++)作者 (yorker)時間10年前 (2016/05/15 14:48), 10年前編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
設定結構data 其結構變數student[5] 設定一函數 struct data best(struct data student[]) { 這裡取最大值的index return student[index]; } 想問要怎麼在main中接受這個傳回值 我設student[4]=struct data best(student); 跟另外定義一個struct data temp; temp=struct data best(student); 這兩種都不行。。 請問下傳回值為結構元素怎麼接受0.0 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.82.188.254 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1463294930.A.F3F.html ※ 編輯: Neverfor (111.82.188.254), 05/15/2016 14:55:08

05/15 15:04, , 1F
回傳int 你會寫 num = int func(); 嗎?
05/15 15:04, 1F

05/15 15:04, , 2F
寫 temp=best(student); 就好
05/15 15:04, 2F
我暈了我 竟然忘記函數怎麼用 感恩 ※ 編輯: Neverfor (111.82.188.254), 05/15/2016 15:08:52

05/15 15:14, , 3F
我想把index傳回來 temp = student[best()];
05/15 15:14, 3F
文章代碼(AID): #1NE1lIy_ (C_and_CPP)
文章代碼(AID): #1NE1lIy_ (C_and_CPP)