2.2 Auto

Auto variables in C are allocated upon the entry of a block, and deallocated upon the exit of a block. As a result, auto variables are only suitable for localized use that do not require a variable to retain its value across the exit and reentry of a block.

The main advantage of auto variables is that they are allocated on-demand. This means that there is little waste of resources. However, for the purposes of data structure, auto variables are not particularly useful.

Auto variables are allocated as follows:

{
  struct X pool[256];
  int i;

  ...
}



Copyright © 2006-08-28 by Tak Auyeung