server-api-calloc

原型

用于配置内存空间

1
2
3
4
5
6
// nmemb:要分配内存个数
// size:要分配的每个内存大小
//
// return:
// 若配置成功则返回一指针,失败则返回NULL。
void *calloc(size_t nmemb,size_t size);

使用参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<stdlib.h>

struct test
{
int a[10];
char b[20];
};

int main()
{
struct test *ptr = calloc(sizeof(struct test), 10);

free(ptr);

return 0;
}