代码改变世界

C run-time 三个申请内存函数

2009-10-05 10:04  Iron  阅读(194)  评论(0编辑  收藏  举报

Allocates an array in memory with elements initialized to 0.

 void *calloc( 
   size_t num,
   size_t size 
);
Parameters

num
Number of elements.

size
Length in bytes of each element.
---------------------------------------------------------------------------------------------------------------------------
Allocates memory blocks.

 void *malloc(
   size_t size 
);
Parameters

size
Bytes to allocate.

---------------------------------------------------------------------------------------------------------------------------
Reallocate memory blocks.

 void *realloc(
   void *memblock,
   size_t size 
);
Parameters

memblock
Pointer to previously allocated memory block.

size
New size in bytes.