automatic variable

(thing) by _Yup Fri May 11 2001 at 23:45:37

A term used in computer programming. It refers to those variables local to specific functions that are automatically allocated on the stack during each invocation of the function.

Example:

	void
	swap(int *a, int *b)
	{
		int temp;	/* Automatic Variable! */

		temp = *b;
		*b = *a;
		*a = temp;
	}

They're called automatic because upon each invocation of a function, storage space for these variables is automatically allocated on the stack for them.

Note: The keyword "auto" exists for explicitly declaring an automatic variable within a block. Such as:

        ...
        {
                auto int temp;
                ...
        }
But since a variable within a block is automatic by default (as oposed to extern or static), the use of auto is redundant and obsolete.

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.