我最近決定嘗試使用C++,並且馬上就關閉了,我不知道自己在做什麼。 我安裝了Microsoft Visual C++ Express 2010.與Eclipse中的Java一樣,我創建了一個新項目並在源文件夾中創建一個新文件。 這裏是我的代碼:無法編譯Hello World程序
#include <iostream>
using namespace std;
int() main
{
cout << "Hello World!\n";
return 0;
}
而且我這是我所得到的,當我嘗試建立:
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1> Hello.cpp
1>c:\users\dylan\documents\visual studio 2010\projects\helloworld\helloworld\hello.cpp(4): error C2059: syntax error : ')'
1>c:\users\dylan\documents\visual studio 2010\projects\helloworld\helloworld\hello.cpp(5): error C2143: syntax error : missing ';' before '{'
1>c:\users\dylan\documents\visual studio 2010\projects\helloworld\helloworld\hello.cpp(5): error C2447: '{' : missing function header (old-style formal list?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
編輯:啊該死的,這是一個令人難以置信的愚蠢的錯誤。顯然我需要更仔細地看待文本。感謝所有迴應的人。
int()main'應該是int main()'。 – jrok
爲什麼在你決定說出一種你以前從未用過的新語言「讓我們問Stack Overflow」而不是「Let's go and learn this language」之後,WHY是你的第一反應? –
Man ...這是一個**啞巴**問題。對不起,但是。嚴重的是,**爲什麼你不能仔細閱讀這個初學者的教程仔細?** – 2013-10-27 18:51:30