注册 登录
编程论坛 C++教室

linux系统下用gcc编译c++出错。初学者,请大家帮忙。

zengxiangze 发布于 2011-03-30 18:02, 897 次点击
源代码是:
#include <iostream>
int main()
{float x;
int i;
x=3.6;
i=(int)x;
cout <<"x="<<x<<",i="<<i<< endl;
return 0;}

编译命令是:beibei@ubuntu:~/桌面$ gcc -Wall zeng.C -o zeng
可是出现下列错误:zeng.C:7: error: ‘cout’ was not declared in this scope
                               zeng.C:7: error: ‘endl’ was not declared in this scope

这是怎么个情况????
3 回复
#2
xin3109232011-03-30 18:15
哈哈  跟我用的是一样的版本  ubuntu   只不过我才用ubuntu几天   不懂linux系统,入门
#3
pangding2011-03-30 21:55
首先你得
using namespace std;

另外,编译 C++ 的源码,要用 g++。
就是写:
g++ -Wall zeng.C -o zeng
#4
j8678607742011-04-03 14:33
std::cout<<
1