Why does the program exit with exception when i use the array variant instead of the pointer.
int main()
{
// unsigned char data[1920 * 1080 * 4]; this causes the exception
unsigned char* data = new unsigned char[1920 * 1080 * 4];
std::cout << "Hello World!\n";
}
>Solution :
Automatic storage duration (the commented case) has a limit of about 1Mb on current platforms.
Dynamic storage duration (the uncommented case) allows for much larger contiguous blocks to be allocated. (In excess of 1Gb on current platforms).
The C++ standard doesn’t mandate specific limits.