Advertisement
lIlIlIlIIlI

Introduction_variablesDefinition

Sep 9th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. /*  
  2. 時間(變數的生滅lifecycle):
  3.     動態變數(dynamic variables):生於宣告,終於右大括號 }。
  4.     靜態變數(static variables):生於程式啟動,終於程式結束(自始至終都在)。
  5.    
  6. 空間(可以存取變數的範圍scope):
  7.      區域變數(local variables):在任何大括號內宣告的變數,即為區域變數。
  8.      全域變數(global variables):不存在。
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. int a; // dynamic variables, global variables
  14. int main(){
  15.     static int b; // static variables, local variables
  16.     int c; // dynamic variables, local variables
  17.     return 0;
  18. }
  19.  
  20. /*
  21. int a; // 全域變數,  動態變數
  22.  
  23. {
  24.     static int a; // 區域變數, 靜態變數
  25.     int a; //區域變數, 動態變數
  26. }
  27.  
  28. int main(){
  29.  
  30.  
  31. }
  32.  
  33. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement