home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
datafiles
/
text
/
c_tutor
/
scope.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-27
|
930b
|
41 lines
int count; /* This is a global variable */
main()
{
register int index; /* This variable is available only in main */
head1();
head2();
head3();
/* main "for" loop of this program */
for (index = 8;index > 0;index--) {
int stuff; /* This variable is only available in these braces*/
for (stuff = 0;stuff <= 6;stuff++)
printf("%d ",stuff);
printf(" index is now %d\n",index);
}
}
int counter; /* This is available from this point on */
head1()
{
int index; /* This variable is available only in head1 */
index = 23;
printf("The header1 value is %d\n",index);
}
head2()
{
int count; /* This variable is available only in head2 */
/* and it displaces the global of the same name */
count = 53;
printf("The header2 value is %d\n",count);
counter = 77;
}
head3()
{
printf("The header3 value is %d\n",counter);
}