alloca()与malloc的区别

void*   realloc(void*   ptr,   unsigned   newsize);  
void*   malloc(unsigned   size);  

void*   alloca(unsigned   size);  

void*   calloc(size_t   numElements,   size_t   sizeOfElement);  
都在stdlib.h函数库内  

 

 

alloca 和malloc 的 区别我是alloca是在栈上申请  
malloc是在堆上申请

 

alloca is not Standard and cannot be used in programs which must be widely portable, no matter how useful it might be. Now that C99 supports variable-length arrays (VLA's), they can be used to more cleanly accomplish most of the tasks which alloca used to be put to.

void fun()

{

int size = INT_MAX / 8;
char a[size];

}

你可能感兴趣的:(c,Arrays,fun)