Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Difference between data assignment in pointer and a variable

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading