Hello ,
i have read the manual page of alloca ,
it is documented there that "alloca works similar to the malloc but it allocates memory from stack and frees automatically.
i can't get how can i use that in a program .
if i'm not wrong can i use that like :
#include<stdio.h>
#include<alloca.h>
int main()
{
void *p;
p=alloca(200);
if(p==NULL)
{
printf("alloca failed\n");
exit(1);
}
strcpy(p,"Hello");
printf("%s\n",p);
printf("%u\n",p);
return 0;
}
and what is the advantage of such a function.
even if i use array it also allocates memory from the stack and memory will be freed automatically.
what is the more advantage its having than array