auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while
特徵:全小寫、IDE 高亮顯示、不可作變量名。
test ≠ Test。max_count 優於 x1。maxCount 或下劃線 max_count。MAX_SIZE,宏同。| 標識符 | 合法 | 原因 |
|---|---|---|
test1 | 是 | |
123abc | 否 | 數字開頭 |
int | 否 | 關鍵字 |
a_b | 是 | |
a-b | 否 | 含減號 |
// 註釋,至行尾。/* 註釋 */,可跨行。// 可嵌套 /* */;/* */ 可嵌套 //;/* */ 不可嵌套 /* */。總結
關鍵字、標識符、註釋是 C 程序的「字母表、單詞、標點」。熟練掌握命名規範、註釋嵌套規則、IDE 高亮語義,能讓代碼可讀、可維護、可協作。