Re: [問題] C 結構指標的記憶體配置寫法

看板C_and_CPP (C/C++)作者 (某數要尋找暑假工作機會)時間15年前 (2010/07/20 14:47), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/2 (看更多)
這樣就可以跑 #include <stdio.h> #include <stdlib.h> int main() { typedef struct { int area; int width[15]; int height[15]; } MS; MS *burst; burst = (struct MS*)malloc(sizeof(MS)*40); int n; for( n = 0 ; n<15 ; ++n ) { burst->width[n] = n*10; burst->height[n] = n*10; burst->area = burst->width[n]*burst->width[n]; printf("burst->area = %d\n",burst->area); } return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.240.38.21

07/20 14:47, , 1F
騙文章數>"< 其實可以codepad
07/20 14:47, 1F
※ 編輯: x000032001 來自: 123.240.38.21 (07/20 14:49)

07/20 17:05, , 2F
嗯嗯 還是謝謝大大囉:D
07/20 17:05, 2F
文章代碼(AID): #1CHKPpxQ (C_and_CPP)
文章代碼(AID): #1CHKPpxQ (C_and_CPP)