fatal error C1083 Cannot open include file 'iostream.h' No such file or directory 的解决方法

VC++6.0 中的一段程序,有用到iostream.h中的标准输入输出流,直接用 VS2005编译器编译的时候报错“Cannot open include file: 'iostream.h': No such file or directory”。

旧的源文件如下:

#include
int main()
{

:cout < <"hello world" <

return 0;
}

一直报上面的错误,无法通过编译。

原因和解决方法,如下:

#include 是VC6以前的写法。

#include

using  namespace  std;

这个是标准库的写法。标准库把这些个文件都放到std这个namespace里面了。

可以到VC/include看看和VC6.0的区别,是iostream而不是iostream.h。

注意 和 是两个不同的东西

是STL库

是兼容于c的库

所有STL库都在std::名空间下

std::cout是 里面的对象

namespace std: 所有的C++ Standard Library Class都包含在这个叫std的name

space里。比如 , , 等等。所以当你使用它们其中的class时

,需要加入这个语句,using namespace std; 不然编译器报错。

本例可用两种方法,如下:

方法一:

#include
using spacename std;
int main()
{
  cout < <"hello world" <   return 0;
}

方法二:

#include
int main()
{
  std::cout < <"hello world" <   return 0;
}

以上两种方法修改后的代码就可以在 VS2005 下编译通过

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值