#include <stdio.h>
int main(void) {
printf("To C, or not to C: that is the question.\n");
return 0; // 向作業系統返回退出狀態碼
}
| 代碼 | 含義 |
|---|---|
#include <stdio.h> | 引入標準輸入輸出庫頭文件,提供 printf 聲明 |
int main(void) | 主函數,無參數,返回 int,程序入口 |
printf(...) | 格式化輸出到標準輸出,\n 換行 |
return 0; | 正常退出,非 0 表示異常 |
gcc -std=c11 -o pun pun.c ./pun # 輸出:To C, or not to C: that is the question.
puts() 替代 printf(); 或 #include,觀察編譯錯誤信息從第一個程序開始,養成「標準、規範、可移植」的編碼習慣。