You are not logged in. Please login at to post your questions!


Memory Fragmentation

why codechef compiler is unable to provide contiguous memory location to the array of size greater than 10^6 in local scope statically whereas it is possible dynamically.

asked 28 Jun '16, 11:47

demo01's gravatar image

accept rate: 12%

Yes, you cannot locally declare an array of size 10^6 in gcc compiler because when you declare an array in a function it gets allocated in stack memory and this memory has less space as compared to heap memory.

Instead of direct declaration use malloc function for the declaration(Array will be allocated in heap memory).

It does not matter whether you declare the array of such size statically or dynamically, in both the cases yo will get the run time error.


answered 28 Jun '16, 12:51

mayur_kharche's gravatar image

accept rate: 100%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 28 Jun '16, 11:47

question was seen: 382 times

last updated: 28 Jun '16, 12:51