Below is my simple code snippet.
#include <iostream>
using namespace std;
bool testAllocArray(const unsigned int length)
{
char array[length]; //--------------------------(1)
return true;
}
int main(int argc, char** argv)
{
testAllocArray(1024);
return 0;
}
At statement (1), the array seems to be not allocated in heap. I was thinking, it would be allocated in the heap. If it is allocated in the stack, doesn't this lead to crash of some spurious value length as the stack size is pretty much small?