函数名: calloc
功 能: 分配主存储器,分配内存的大小为nelem*elsize,并将其初始化
用 法: void *calloc(size_t nelem, size_t elsize);
程序例:
#include <stdlib.h>
#include
int main(void)
{
char *str = NULL;
/* 分配内存空间 */
str = (char*)calloc(10, sizeof(char));
/* 将hello写入*/
strcpy(str, "Hello");
/*显示变量内容*/
printf("String is %s
", str);
/* 释放空间 */
free(str);
return 0;
}