refer to What is the difference between malloc and calloc functions?

簡單的說,

calloc(m, n);

就等於

p = malloc(m * n); memset(p, 0, m * n);

為了避免沒有initialize所配置的記憶體而造成奇怪的結果

用calloc會比較好:)
文章標籤
全站熱搜
創作者介紹
創作者 iceis 的頭像
iceis

.: iceis' Blog :.

iceis 發表在 痞客邦 留言(0) 人氣(1,134)