[問題] 傳入一個struct的陣列至function????
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 )
( 未必需要依照此格式,文章條理清楚即可 )
遇到的問題: 不能傳址呼喚一個struct的陣列
程式跑出來的錯誤結果:只能傳值...
開發平台: (例:Dev-pas
有問題的code:
#include <stdio.h>
#include <conio.h>
struct test{
int mark;
};
int check(struct test[10]);
int main(void){
struct test student[10];
student[1].mark=1;
check(&student[10]);
printf("%d\n", student[1].mark);
printf("%d\n", check(&student[10]));
getch();
return 0;
}
int check(struct test data[10]){
data[1].mark=3;
printf("check-pt\n");
return data[1].mark;
}
result of program:
check-pt
1
check-pt
3
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 116.49.84.46
推
11/18 21:42, , 1F
11/18 21:42, 1F
※ 編輯: mahoihei 來自: 116.49.84.46 (11/18 21:46)
→
11/18 21:46, , 2F
11/18 21:46, 2F
※ 編輯: mahoihei 來自: 116.49.84.46 (11/18 21:49)
推
11/18 21:53, , 3F
11/18 21:53, 3F
→
11/18 21:54, , 4F
11/18 21:54, 4F
11/18 21:54
※ 編輯: mahoihei 來自: 116.49.84.46 (11/18 21:55)
→
11/18 21:56, , 5F
11/18 21:56, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
-4
5