c - Static memory allocation of array at compile time -


How to compile time determines the size of the compiler below the array?

  int n; Scanf ("% d", & amp; n); Int a [n];  

This is different from dynamic allocation (other than memory is allocated in the pile for dynamic array).

If possible, please explain this in the context of activation stack memory how the array is allocated to the image.

The size of the array is not set at compile time; It is determined at run time that array is allocated at that time, n is a known value in a typical implementation where the automatic variable is allocated on the program stack, the stack pointer has several inputs Will be adjusted to make room for It becomes parts of the stack frame and when it comes out of the scope, it will be automatically recovered.

This code was not valid in the C90; The C90 requires all the variables to be declared at the beginning of the block, so the mixing of announcements and thus code was not allowed. Variable-length arrays and mixed codes and announcements were introduced in the CAM.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -