#include
using namespace std;
int main() {
cout << "Hello C" << endl;
return 0;
}
提問者以為這是 C 程式,實際上這是標準的 C++ 程式。關鍵差異在於:
#include <iostream> 是 C++ 標準庫頭檔,C 語言使用 <stdio.h>。using namespace std; 為 C++ 命名空間用法,C 無此機制。cout << ... << endl; 為 C++ 流輸出,C 使用 printf()。#include
int main() {
printf("Hello C\n");
return 0;
}
程式碼本身無語法錯誤,可正常編譯執行,但屬於 C++ 範疇。初學者需區分兩者的標準庫與輸出方式。