最近比較閒,正好借這個時間看看PHP源碼,有看到不懂的地方會記錄一下,以後會把問題以及答案都寫下來。數組
1.C語法生疏須要複習。(後面會寫相關複習的內容)數據結構
struct是一種數據結構,就是一組相關數據的集合,比方說學生的姓名,性別,身高等信息的集合,由於數組不能存放這樣的信息(數組內的元素長度和類型必須一致),因此struct就誕生了。.net
struct學習代碼(比較基礎)參考http://blog.csdn.net/huqinwei987/article/details/23625823code
//struct的定義以及內部成員的賦值 struct 結構體名稱 { 成員列表 } //舉例 學生的結構體 struct student { int id; //學生id char *name; //姓名 float weight;//體重 int sex; //性別 } //結構體的內部成員賦值 方式一(逐一賦值,太麻煩) struct student xiaohei; xiaohei.id = 0; xiaohei.name = "寧金"; xiaohei.weight = 52.1; xiaohei sex = 1; //結構體的內部成員賦值 方式二(比較方便哈) struct student xiaohei = {1,"xiaohei",52.1,1}; //結構體初始化定義(是一種簡寫定義同時初始化一個結構體) struct school { }Sun; //能夠理解爲 struct school { }; struct school Sun; //結構體嵌套結構體 struct teacher { int id; struct { char *province; char *city; }address; }; struct teacher nj; nj.id = 1; nj.address.province = "shanxi"; nj.address.city = "yuncheng"; //結構體和數組 struct datatype { int arr[3]; int temp; }; struct datatype array[3] = { {12,12,12,0}, {13,13,13,1}, {14,14,14,2} }; //這裏留兩個問題 1.結構體的引用 如何使用 2.可變長結構體的實現
(2 數據結構blog
把線性表,單向鏈表,棧,隊列,樹,圖都複習一遍。(有點難)
隊列
寫到這發現C須要複習的太多了,之前沒好好學。因此決定暫時把這篇擱下,把C複習完再繼續吧。
ci