下列C 語言敘述片段執行結果為何?struct iptr { int *p1; int *p2; }; int main (int argc, char *argv[]){ struct iptr newptr; int a=1,b; newptr.p1=&a; newptr.p2=&b; *newptr.p2=2; printf("%d,%d,%d,%d",a,b,*newptr.p1,*newptr.p2); return 0; }

- (A) 1,2,0,0
- (B) 1,0,0,2
- (C) 1,2,1,2 正確答案
- (D) 語法錯誤
官方答案:(C)1,2,1,2
詳解
p1指向a、p2指向b,*p2=2使b=2,輸出1,2,1,2。
同章其他題目:113 年初等考試
題目與答案照初等考試資料處理大意(統計)官方公開題庫(110-115 版)收錄;詳解是我寫的整理,正式內容以主管機關公告為準。