我刚开始学习C语言,(当然)在指针方面遇到了一些困难 :)
给定以下代码片段:
int *storage, *storage_p;
storage = malloc(sizeof(int[GROW_BY]));
storage_p = storage;
// do something with storage, using storage_p
free(storage);
storage = NULL;
需要声明两个变量才能使用malloc()
分配的数据吗?像我这样创建一个storage
和storage_p
是好的实践吗?如果不是,应该怎么做?