《返校》台詞:「你是忘記了,還是害怕想起來?」
^
讓 x == 0
變 normal casetest1 是一個 int
type 的函式 : int (int)
fptr1 是一個 pointer to function with returning type : int(*)(int)
*fptr1 因為 function pointer(fptr1) 搭配 * 運算子的運算視為 function designator ,且 fptr1 有 returning type,所以轉變成pointer to function returning type : int (int)
若沒有 function designator ,在 *fptr1 時會抓到錯誤的程式段。
以上面的例子來說,會抓到 empty function。
Reference
-Why we need function designator
A driver in software provides a programming interface to control and manage specific lower level interface that is often linked to a specific type of hardware, or other low-level service.
在 Readme 中提到:
scripts/driver.py : The C lab driver program, runs qtest on a standard set of traces
Driver 扮演是一個操作 qtest 執行一連串的 task (例如:q_insert_head . q_free …等等)的角色。
想法是原本 queue 的指向關係為 A → B → C → D → E → NULL
reverse 即是將關係反過來:原本 A->next = B 改成 B->next = A
最一開始先將 cur 指向 B , q->head->next 指向 NULL (即 A ->next = NULL),再將 q->tail 換成 q->head (q->tail 指向 A)
再來就是換個別 node 的 next 關係
STEP1. 儲存 cur->next 先儲存起來
STEP2. 先讓 cur 指向我們所想對調的 next 關係 (cur 指向 B , B->next 要指向 A)
STEP3. 再將 q->head 更新為 cur (B → A → NULL)
STEP4. 最後更新 cur 為下一個要對調 next 關係的 node