5.4. Rules of Scope

Scope refers to what variables are available to access (read or modify) at a given place in the program. The scope of a variable is determined by the rules of the C compiler, whether the variable is declared as a global variable or local to a function, and by the variable’s storage class.

This portion of Topic 4 may seem more related to data declarations, which was discussed in Topic 2, than to functions. However, issues related to the scope of variables do not come up until one considers functions. Thus, we now take a bit of an aside from our discussion of functions to learn a little more about data variables.

5.4.1. arguments, local variables, global variables

The function can not see the local variables of the calling function. It does have access to three types of data.

arguments

The names of arguments are defined in the first line of the function definition.

function local variables

Variables defined within the function.

global variables

Variables declared out side of any function.