Khác nhau giữa malloc() và calloc()

malloc() chỉ có 1 argument, là số byte mà nó allocate trong mem.

calloc() có 2 arguments: 
1) Số block nó allocate. 
2) Kích cỡ mỗi block tính theo byte.

malloc không ghi trước nội dung các bytes nó allocate, calloc sẽ set tất cả các byte mà nó allocate thành 0.

Leave a Reply

Your email address will not be published. Required fields are marked *