回 帖 发 新 帖 刷新版面

主题:请教!这段代码超简单~可是为什么编译不过

#inculd<iostream> 
using namespace std; 
int main() 

  cout<<"This"<<"is"; 
  cout<<"a"<<"C++"; 
  cout<<"program."<<endl; 
  return0; 

编译报错 
first.cpp:1:2: error: invalid preprocessing directive #inculd 
first.cpp: In function 'int main()': 
first.cpp:5: error: 'cout' was not declared in this scope 
first.cpp:7: error: 'endl' was not declared in this scope 
first.cpp:8: error: 'return0' was not declared in this scope 

我用的是DJGPP 
刚刚学习C++希望大家多指教!

回复列表 (共8个回复)

沙发

return0; 
这是什么?

板凳

这个~
主函数是int main()啊所以末尾有返回零值

这个代码是照抄书上的我就是想看看DJGPP是不是安装正确
可是就是编译不过去
是不是需要设置什么环境变量的?

麻烦大家指点一下
这个问题困扰好久~

3 楼

return 0;
这是返回0

4 楼

#include <iostream>//不是#inculd<iostream>
using namespace std;
int main()
{
  cout<<"This"<<"is";
  cout<<"a"<<"C++";
  cout<<"program."<<endl;
  return 0;//返回不是return0,这是一个整体,编译器不认识的哦
}

5 楼

细心啊,楼主好粗心哦,加油

6 楼


呵呵~真的咧
我的确是很粗心咯[em8]

7 楼


谢谢谢谢楼上的楼上的谢谢楼上的楼上的楼上的!

8 楼


include的e没有写

我来回复

您尚未登录,请登录后再回复。点此登录或注册