关键字malloc的作用是什么?

来源:百度知道 编辑:UC知道 时间:2024/05/29 11:50:36

malloc不是关键字,是一个申请内存的函数!
msdn解释如下:
void *malloc(size_t size );

size
Bytes to allocate.

malloc returns a void pointer to the allocated space or NULL if there is insufficient memory available. To return a pointer to a type other than void, use a type cast on the return value. The storage space pointed to by the return value is guaranteed to be suitably aligned for storage of any type of object. If size is 0, malloc allocates a zero-length item in the heap and returns a valid pointer to that item. Always check the return from malloc, even if the amount of memory requested is small.

申请变量的内存空间,从而可以使用free函数释放

为数据申请存储空间,C语言的