Rob said:
Say I have the following code:
All right: "I have the following code."
void foo(int some_int);
....
int x = 5;
foo(x);
....
void foo(int some_int)
{
printf("%d\n", some_int);
}
Would 'some_int' be considered a local variable, (which happens to be
initialised externally)? If not, what would it be considered as?
The identifier `some_int' appears in two contexts: once
in the declaration of foo() and once in its definition. In
the declaration it's really just commentary: A name that
never gets used and could just as well have been omitted or
replaced with another. You could have written the declaration
as `void foo(int);' or as `void foo(int huge_array_of_float);'
with exactly the same effect.
In the definition, `some_int' is the name of the function's
formal parameter. The parameter behaves very much like a local
variable that has been initialized with the value of the
corresponding argument expression provided by the caller. The
parameter exists and has its value when foo() starts to execute,
and it continues to exist until foo() returns or otherwise ceases
to execute. Like a local variable it retains its value until and
unless you assign a new one to it, and then retains that value.
Technically, though, it is not a local variable but a parameter --
but this is a tautology, because technically there is no such
thing as a "local variable" in the languge.