#defineA50constintB=40;staticintarray[A];//正確staticintarray2[B];//錯誤constintC=2*A;//正確constintD=2*B;//錯誤intmain(){}疑惑const定義常量是不是發生在編譯時,所以在程序預處理階段不能對數組大小進行初始化或者對值進行初始化,而#define宏發生在預處理階段,可以用實體對數組大小初始化時出現的宏進行宏展開。我這樣理解對嗎望更詳細的補充
C語言中#define和const疑惑
FFIVE
2019-04-14 11:21:57