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會比較好:)
全站熱搜
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會比較好:)