0

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";
}
Summit
  • 2,112
  • 2
  • 12
  • 36

1 Answers1

3

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.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483