top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How memory can be allocated for the array in the following program?

+2 votes
#include <stdio.h>

int main(void)
  int a=17;

  int arr[a];


Memory for array "arr" should be allocated at compile time but in this case it takes the value of "a" from the user(run-time) and allocates the same size for the array.

posted May 12, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Nice question,
Please note that allocation of memory is done at run time not compile time,
During compilation compiler will just create a table for this variable, but actual allocation is done at run time.

answer May 13, 2016 by Chirag Gangdev
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.