What is the difference between
void *bytes = alloca(size);
and
char bytes[size]; //Or to be more precise, char x[size]; void *bytes = x;
…where size is a variable whose value is unknown at compile-time.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
alloca()does not reclaim memory until the current function ends, while the variable length array reclaims the memory when the current block ends.Put another way:
alloca()can be supported (in a fashion) on any C89 compiler, while the variable length array requires a C99 compiler.