home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / program / a / c_interp / Examples / variables < prev   
Encoding:
Text File  |  1993-12-13  |  485 b   |  35 lines

  1. @* An example of variable scope *@
  2.  
  3. @* The following is global *@
  4. int value;
  5.  
  6. main()
  7. {
  8. char a_byte;
  9. char string[8];
  10. int  i;
  11.  
  12. value=10;
  13. printf("Value 1: %d  Value 2: %d\n",value,get_value());
  14.  
  15. strcpy(string,"ABCDEFG");
  16.  
  17. a_byte=*(string+2);
  18. printf("The byte is: %c\n",a_byte);
  19.  
  20. a_byte=string[4];
  21. printf("The byte is: %c\n",a_byte);
  22.  
  23. printf("Enter a number: ");
  24. scanf("%d",&i);
  25. printf("\nYou entered %d!\n",i);
  26. }
  27.  
  28. get_value()
  29. {
  30. @* The following is local *@
  31. int value=20;
  32.  
  33. return value;
  34. }
  35.