home *** CD-ROM | disk | FTP | other *** search
- @* An example of variable scope *@
-
- @* The following is global *@
- int value;
-
- main()
- {
- char a_byte;
- char string[8];
- int i;
-
- value=10;
- printf("Value 1: %d Value 2: %d\n",value,get_value());
-
- strcpy(string,"ABCDEFG");
-
- a_byte=*(string+2);
- printf("The byte is: %c\n",a_byte);
-
- a_byte=string[4];
- printf("The byte is: %c\n",a_byte);
-
- printf("Enter a number: ");
- scanf("%d",&i);
- printf("\nYou entered %d!\n",i);
- }
-
- get_value()
- {
- @* The following is local *@
- int value=20;
-
- return value;
- }
-