c each types float null 网上找到的英文解释如下: Boththe malloc() and the calloc() functions are used to allocate dynamicmemory. Each operates slightly different from the other. Boththe malloc() and the calloc() functions are used to allocate dynamicmemory. Each operates slightly different from the other. malloc() takesa size and returns a pointer to a chunk of memory at least that big: void *malloc( size_t size ); calloc() takes a number of elements, and the size of each, and returns a pointer to a chunk of memory at least big enough to hold them all: void *calloc( size_t numElements, size_t sizeOfElement ); Thereare one major difference and one minor difference between the twofunctions. The major difference is that malloc() doesn't initialize theallocated memory. The first time malloc() gives you a particular chunkof memory, the memory might be full of zeros. If memory has beenallocated, freed, and reallocated, it probably has whatever junk wasleft in it. That means, unfortunately, that a program might run insimple cases (when memory is never reallocated) but break when usedharder (and when memory is reused). calloc() fills the allocated memorywith all zero bits. That means that anything there you are going to useas a char or an int of any length, signed or unsigned, is guaranteed tobe zero. Anything you are going to use as a pointer is set to all zerobits. That is usually a null pointer, but it is notguaranteed.Anything you are going to use as a float or double is set toall zero bits; that is a floating-point zero on some types of machines,but not on all. The minor difference between the two is thatcalloc() returns an array of objects; malloc() returns one object. Somepeople use calloc() to make clear that they want an array. 下面是网上的中文说明 用 malloc() 函数更好还是用 calloc() 函数更好 函数 malloc() 和 calloc() 都可以用来动态分配内存空间 , 但两者稍有区别。 malloc() 函数有一个参数 , 即要分配的内存空间的大小 : void*malloc(size_tsize); calloc() 函数有两个参数 , 分别为元素的数目和每个元素的大小 , 这两个参数的乘积就是要分配的内存空间的大小。 void*calloc(size_tnumElements,size_tsizeOfElement); 如果调用成功 , 函数 malloc() 和函数 calloc() 都将返回所分配的内存空间的首地址。 函数 malloc() 和函数 calloc() 的主要区别是前者不能初始化所分配的内存空间 , 而后者能。如果由 malloc() 函数分配的内存空间原来没有被使用过,则其中的每一位可能都是 0; 反之 , 如果这部分内存曾经被分配过 , 则其中可能遗留有各种各样的数据。也就是说,使用 malloc() 函数的程序开始时 ( 内存空间还没有被重新分配 ) 能正常进 行 , 但经过一段时间 ( 内存空间还已经被重新分配 ) 可能会出现问题。 函数 calloc() 会将所分配的内存空间中的每一位都初始化为零 , 也就是说 , 如果你是为字符类型或整数类型的元素分配内存 , 那麽这些元素将保证会被初始化为 0; 如果你是为指 针类型的元素分配内存 , 那麽这些元素通常会被初始化为空指针 ; 如果你为实型数据分配内存 , 则这些元素会被初始化为浮点型的零。 http://blog.csdn.net/wstarx/article/details/875853