Local variable

This is an old revision of this page, as edited by 202.144.136.4 (talk) at 14:05, 27 March 2008. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, a local variable is a variable that is given local scope. Such a variable is accessible only from the function or block in which it is declared. Local variables are contrasted with global variables.

In most languages, local variables are automatic variables stored on the call stack directly. This means that when a recursive function calls itself, local variables in each instance of the function are given separate memory address space. Hence variables of this scope can be declared, written to, and read, without any risk of side-effects to processes outside of the block in which they are declared.