标签:style io ar sp c on 代码 r size
代码:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const size_t SIZE = 5;
// 函数malloc的返回值类型是void*
// 函数原型:void* malloc(size_t)
int* p = malloc(SIZE * sizeof(int));
// int* p = (int*)malloc(SIZE * sizeof(int));
// 如果发生错误则返回空指针
// p == NULL 等价于 !p
if (p == NULL) {
exit(EXIT_FAILURE);
}
// 函数free释放存储空间
// 函数原型:void free(void*)
free(p);
return EXIT_SUCCESS;
}
标签:style io ar sp c on 代码 r size
原文地址:http://my.oschina.net/Xwoder/blog/324405