2
我是Linux Ubuntu 11.10的新手,并且具有基本的C++风险。C++编译但执行时出错
我通过
sudo apt-get install build-essential
安装了G ++,在我的主目录中创建一个目录的cpp。然后我在CPP目录
#include <iostream>
using namespace std;
int main() {
cout << "Hello !" ; return 0;
}
写了一个程序HELLO.CPP和使用
g++ -W hello.cpp -o hello
程序编译没有任何错误/警告编译。当我尝试执行该文件
./hello.cpp
我收到错误消息:
line 3: using: command not found
line 6: syntax error near unexpected token `('
line 6: `int main() {'
我试图寻找在很多帖子,但未能解决这个问题。我在Windows上有MS VisualStudio,但我宁愿在Ubuntu上学习C++。提前致谢。
非常感谢。这工作。我真的觉得很愚蠢..很清楚,我有很长的路要走.. – sunny 2012-01-30 20:16:18
@ user1178883-不用担心,也不觉得愚蠢!你有一个真正令人兴奋的旅程在你面前。不要为了小东西而流汗。 :-) – templatetypedef 2012-01-30 20:18:16
@ user1178883:是的,别担心。每个人都一直在反对这样的事情。你唯一能做的就是说“呃!”。 :-) – Florian 2012-01-30 21:03:46