用VS2008编译C++的时候系统提示【 无法打开包括文件:“iostream.h”:】

本文解答了在Visual Studio 2008中使用C++编程时遇到的编译错误问题,特别是当尝试包含过时的iostream.h文件时出现的错误。文章提供了正确的包含声明,并推荐使用iostream,同时介绍了如何避免此类问题,包括更新编程书籍和调整编程习惯。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用VS2008编译C++的时候系统提示【1>e:\我的程序\ilove\ilove\main.cpp(3) : fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory】应该怎样修改呀?
程序段
#include "stdafx.h"
#include
<iostream.h>
int main()
{
 
char *name,*num;
 
float score[3];
 
float StuAve[20];
 
bool flag;
 cout
<<"请输入要处理学生的个数:"<<endl;
 
int m;
 
float temp;
 student stu[
20];
 cout
<<"请输入学生的个数";
 cin
>>m;
 
for(int n=0;n<m;n++)
 {
  cin
>>name>>",">>num>>",">>score[3];
 }
 
for(n=0;n<m;n++)
 {
  flag
=false;
  
for(int j=m;j>0;j--)
   
if(stu[j].getStuAve()>stu[j-1].getStuAve())
   {
    temp
=stu[j].getStuAve();
    stu[j].getStuAve()
=stu[j-1].getStuAve();
    stu[j
-1].getStuAve()=temp;
    flag
=true;
   }
   
if(!flag)
    
break;
 }
 cout
<<"成绩最好的学生的成绩是:"<<StuAve(float stu[0].getStuAve());
 
float sum0,sum1,sum2;
 
for(n=0;n<m;n++)
 {
  sum0
+=stu[n].getscore(score[0]);
  sum1
+=stu[n].getscore(score[1]);
  sum2
+=stu[n].getscore(score[2]);
 }
  
float couScore1,couScore2,couScore3;
  couScore1
=sum0/m;
  couScore2
=sum1/m;
  couScore3
=sum2/m;
  cout
<<"每门课程的平均分数为:"<<couScore1<<" "<<couScore2<<" "<<couScore3<<endl;
 
return 0;
}


=====================================================================

o 2008 和win7系统本身存在不兼容性问题。很多程序不能运行也是很正常的,这是微软做的不好的地方。当然也有可能是软件安装的问题。如果你确信软件安装没问题的话,那就是不兼容性问题了。
我的建议是:如果你真想好好学C++的话,建议去装XP系统。win7系统存在很多问题,不仅和visual studio 2008 存在兼容性问题,而且和如wince系统等软件都存在兼容性问题。我买的电脑是thinkpad的,自带的也是win7正版系统,现在已经重装XP系统了。
还有你给的代码例子也不太好,见如下分析:
#include <iostream.h>
main()
{
 cout
<<"fbdsfkj"<<endl;

代码是没有问题,但是上面这种编法是很不好的编程风格,混合了C和C
++,在VC6.0下可以编译运行,但这样写不好。好的C++写法应是:
#include 
<iostream>
using namespace std;
int main()
{
 cout
<<"fbdsfkj"<<endl;
 
return 0;
}



=====================================================================


楼主看的书太老了。
新标准98年就出来了,你看的书还在讲98年前的C++,换一本吧。


=====================================================================

把使用#include <iostream.h>
都换成

#include <iostream>
using namespace std;

=====================================================================

#include <iostream> 
using namespace std;

2005好多东西都不用了,像什么.h的头文件基本抛弃了,即使能用也一堆警告
steedhorse 发表于:2007-11-27 00:18:23 4楼
楼主看的书太老了。 
新标准98年就出来了,你看的书还在讲98年前的C++,换一本吧。 

=====================================================================


好像是噢,我现在用的是《面向对象的理论与C++实践》,清华出版的,第一版时间是97年

请推荐一本书,万分感激

=====================================================================

<<C++ Primer 5nd>> C++学习 强烈推荐

=====================================================================

#include <iostream>

using namespace std;

int main()
{
// 实现
return 0;
}


ANSI/ISO C++

=====================================================================
 
#include <iostream.h> 
过时的标准,该改改啦 ^_^ VC2003就已经开始不支持了

 

=====================================================================

#include <iostream>
using namespace std;

//struct my

class my
{
public:
int x;
int y;
int output()
{

cout
<<x<<endl<<<<endl;
return 0;

}
};

int main()
{

my pt;
pt.x 
=5;
  pt.y 
=5;

//cout<<pt.y <<endl<<pt.y <<endl;
pt.output();
getchar();

return 0;
}


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值