Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个功能
int*AllocatedMemory(int n){ int*p=malloc(n*sizeof(int)); return p; }
分配的内存在离开函数后会失去作用域并因此被释放吗?
不。分配的内存malloc与范围无关,需要释放free(或将在程序终止时释放)。
malloc
free