c++ 编译时出错

来源:百度知道 编辑:UC知道 时间:2024/05/23 16:05:04
这是我的程序
#include <iostream.h>
main()
{
intx,y;
cin>>x>>y;
if(x>y)
count<<"最大值"<<=x;
else
count<<"最大值"<<=y;
}
用Microsoft Visual C++ 2008 Express Edition编译的结果
1>------ 已启动生成: 项目: hf, 配置: Debug Win32 ------
1>正在编译...
1>hfcpp.cpp
1>e:\c++\hf\hf\hfcpp.cpp(1) : fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory
1>生成日志保存在“file://e:\c++\hf\hf\Debug\BuildLog.htm”
1>hf - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

首先你的拼写有错误,是cout而不是count,
但是重要的是:

你用的是Microsoft Visual C++ 2008 Express Edition
所以你不能够用
#include <iostream.h>
而要使用#include<iostream>
uisng namespace std;

微软的产品在VC6.0中才支持这种样式的头文件形式。
其实在C++中用.h的形式命名头文件只是为了兼容C语言。
如果你是一名C++程序员的话,建议使用不带.h的头文件
格式,联合using namespace std;使用。
例如在C++<cstdio>头文件的定义中就加入了一条#include<stdio.h>
语句。所以在C++的程序中你加入#include<cstdio>和using namespace std;
就可以使用printf等等函数了。其他的C头文件可以类推!

用什么编译器呢,很多编译器要写名字空间的
#include<iostream>
using namespace std;

main() 最好显示写出返回值,即int main(),很多编译器也不允许缺省

count<<"最大值"<<=x;
是cout.......c代表c++,out代表输出,不是count