c语言的动态内存
前言在C语言中,除了获取变量的指针这种规矩的内存空间,我们还可以通过函数去申请指定大小的内存空间动态mallocmalloc可以申请一块任意尺寸的空间,因为经常一段空间是连续的#include <stdio.h>#include <stdlib.h>int main(void) { int *ptr = NULL; ptr = (int *) malloc(sizeof(int)); // malloc() 返回一个void *类型指针 if (
复制链接