1. struct a 變數可以做另乙個struct ab 的成員
2. struct a 的指標可以指向 struct ab 的變數
3. struct ab 的指標 也可以指向 struct a的變數,but dangerous
4. 一切都在記憶體空間,只是指標指向而已。
/*
* test.h
* * created on: sep 27, 2012
* author: caoj7
*/#ifndef test_h_
#define test_h_
struct date;
typedef struct date date_t;
struct timer;
typedef struct timer timer_t;
#endif /* test_h_ */
/*
* test.c
* * created on: sep 27, 2012
* author: caoj7
*/#include #include #include "test.h"
date_t birth_date = ;
int main(void);
timer_t *birth_timer_ptr = &birth_timer;
printf("birth_timer is: %d %d %d, %d:%d:%d\n",
birth_timer_ptr->date_member.year,
birth_timer_ptr->date_member.month,
birth_timer_ptr->date_member.day,
birth_timer_ptr->hour,
birth_timer_ptr->minute,
birth_timer_ptr->second
);birth_timer_ptr->date_member.year = 2000;
printf("not change value in orginal struct, birth_date.year = %d\n", birth_date.year);
printf("birth_timer is: %d %d %d, %d:%d:%d\n",
birth_timer_ptr->date_member.year,
birth_timer_ptr->date_member.month,
birth_timer_ptr->date_member.day,
birth_timer_ptr->hour,
birth_timer_ptr->minute,
birth_timer_ptr->second
);//let a member pointer point to a whole struct address
date_t *date_ptr = (date_t *)birth_timer_ptr;
printf("%d %d %d\n", date_ptr->year, date_ptr->month, date_ptr->day);
// timer_t *test_timer_ptr = (timer_t *)date_ptr;
printf("%d %d %d, %d:%d:%d\n",
test_timer_ptr->date_member.year,
test_timer_ptr->date_member.month,
test_timer_ptr->date_member.day,
test_timer_ptr->hour,
test_timer_ptr->minute,
test_timer_ptr->second);
test_timer_ptr = (timer_t *)&birth_date;
printf("%d %d %d, %d:%d:%d\n",
test_timer_ptr->date_member.year,
test_timer_ptr->date_member.month,
test_timer_ptr->date_member.day,
test_timer_ptr->hour,
test_timer_ptr->minute,
test_timer_ptr->second);
return exit_success;
}
另乙個自己
人們常說 人貴有自知之明 可是話說回來,又有幾人能真正的了解自己呢?我覺得我就是乙個很沒有自知之明的人。生於89年的我,到了今年的生日就28周歲了。都說三十而立,正所謂成家立業,可以回過頭發現自己可以稱得上 一無是處,一無所有 曾幾何時,還是鄰居家叔叔阿姨教育孩子的榜樣 曾幾何時父母因為自己考個好大...
呼叫另乙個Activity
1 建立主activity 注意通過權重來分配尺寸的方式 元件1 android layout width 0dp android layout weight 1 元件2 android layout width wrap content 2 在主類中指定onclick所對應的sendmessage...
08 另乙個林則徐
子孫若如我,留錢做什麼?賢而多財,財損其志 子孫不如我,留錢做什麼?愚而多財,益增其過。清 林則徐 音訊點我!有一本書,叫 林則徐家書 是林則徐寫給家裡人的信。林則徐大家都知道,先是欽差大臣,去廣東禁菸 鴉片戰爭失敗之後,又成了朝廷的替罪羊,被發配到新疆伊犁,這批家書基本上都是這個時候寫的。過去我們...