twitter
    Find out what I'm doing, Follow Me :)

More On "Automatic" Variables

Observe the function named "head1". It contains a variable named "index", which has nothing to do with the "index" of the main program, except that both are automatic variables. When the program is not actually executing statements in this function, this variable named "index" does not even exist. When "head1" is called, the variables is generated, and when "head1" completes its task, the variable "index" is eliminated completely from existence. Keep in mind however that this does not affect the variable of the same name in the main program, since it is a completely separate entity.

Automatic variables therefore, are automatically generated and disposed of when needed. The
important thing to remember is that from one call to a function to the next call, the value of an
automatic variable is not preserved and must therefore be reinitialized.