`malloc` 函数是在 C 语言中用于动态内存分配的函数,它的头文件是 ``。
当你使用 `malloc` 或其他与内存分配、释放或管理相关的函数时,你需要包含这个头文件。
```c
#include
int main() {
int *ptr = (int*)malloc(sizeof(int));
if (ptr == NULL) {
// 处理内存分配失败的情况
return 1;
}
*ptr = 42;
printf("Value: %d\n", *ptr);
free(ptr);
return 0;
}
```
在这个例子中,我们使用了 `` 头文件来调用 `malloc` 和 `free` 函数。