[問題] 資料結構
假設一個字元 (character) 佔一個 byte,一個整數 (integer) 佔兩個 byte,在記憶體
中,一個字組 (word) 相當於兩個 bytes,字元可以儲存於任何位址,而整數則必須儲存
於一整個字組中。現在以 C 定義一資料結構如下:
struct person {
int id;
char name[20];
int age;
char sex;
} student[100];
若 student[0] 之起始位址為 200 (十進位),請問 student[10].age 之位置為:
(a) 472 (b) 473 (c) 482 (d) 483
ans: c
要怎麼計算阿?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.173.241.2
討論串 (同標題文章)