我寫的一類,我在一個內存分配替代API,並有一個名爲以下my_malloc()
(從教授已經概述基本骨架)功能返回一些我不明白的東西。我不明白這一點(爲size_t)_length回報statment
有人請指教我爲什麼_length
參數在開頭有下劃線,爲什麼return語句的(size_t)
與_length沒有分開?
Addr my_malloc(unsigned int _length) {
/* This preliminary implementation simply hands the call over the
the C standard library!
Of course this needs to be replaced by your implementation.
*/
return malloc((size_t)_length);
}
好,'_length'僅是一個名稱,在開始下劃線看起來像函數參數的命名約定,對於人類,而不是編譯器。表達式(size_t)_length是一個表達式。我建議你在實施任務之前先學習一下C語言。 – user3159253