Surprised with dynamic memory allocation on stack
Posted: Mon Jun 22, 2009 7:33 am
Like the subject says, I surprised with dynamic memory allocation on stack!
I tried this code:
And it worked!!
I'm using dev-cpp on Windows Vista ( gcc (GCC) 3.4.2 (mingw-special) )
( looking the asm code I could see that it does it by calling alloca() )
What I want to know is if this kind of memory allocation is allowed by ANSI C?
And, is there any other kind of stack dynamic memory allocation?
I tried this code:
Code: Select all
int main(int argc, char *argv[])
{
int n;
scanf("%d",&n);
int vector[n];
}
I'm using dev-cpp on Windows Vista ( gcc (GCC) 3.4.2 (mingw-special) )
( looking the asm code I could see that it does it by calling alloca() )
What I want to know is if this kind of memory allocation is allowed by ANSI C?
And, is there any other kind of stack dynamic memory allocation?