在vs2008中的C++无法编译

来源:百度知道 编辑:UC知道 时间:2024/05/17 08:57:12
#includes<iostream.h>
viod main()
{cout<<"hehe";

}

编译为什么会错误???说找不到iostream文件。。为什么啊?
改为#include<iostream>
using namwspace std;才行!
#include<iostream>
#include<fstream>
#include<stdlib>
using namespace std;
void main()
{
}
编译又说找不到stdlib。。。怎么搞的啊?求救!
以上写错了代码只是在这里写错了,不好意思,下面那个为什么说找不到stdlib文件啊??重装vs2008几遍了,还是一样!!
#include<iostream>
#include<fstream>
#include<stdlib.h>
using namespace std;

void main()
{char name[49],number[49],filename[49];
int phy,math.english,computer,c;
ofstream outfile;
cout<<"输入文件名称:";
cin>>filename;
outfile.open(filename,ios::trunc);
if(!outfile)
{cerr<<"文件打开发生错误!"<<endl;
abort();
}
outfile<<"这是一个学生信息文件";
while(cin>>name>>number>>phy>>math>&g

#include<iostream>
#include<fstream>
#include<stdlib.h>
using namespace std;
void main()
{
}
我调试过了,是可以的

etiu2009说的对,我也是初学者,刚好遇到这个问题,再说一些我在网上搜到的知识,帮助理解:
<iostream.h> 的形式是C库, C库不需要std名字空间,
<iostream> 是C++库。需要using namespace std;
iostream.h的形式是C++98之前的库头文件名,那时候还没有加入名字空间(namespace)的概念,所以你include 的时候就直接include iostream.h,不需要加using namespace,C++98中才加入了namespace 的概念,为了减少名字冲突,并把C++的新标准库头文件制定为不加.h后缀的,而使用其中的函数和类方法就必须使用通过namespace来访问了。

你的第一个预处理器指令写错了,多写了一个s,而第二错误:名字空间的英文又写错了,应该是namespace,你把e写成了w.如果像下面这样写一定不会错:
#include <iostream>
using namespace std;
int main()
{
cout << "heeh";
return 0;
}

C++ 标准委员会规定,像 iostream 这类 C++ 标准库不使用扩展名,但是 VC++ 提供了两个版本,即带 .h 扩展名和不带扩展名的版本。

stdlib 是 C 标准库,不遵循以上规定,所以只有 stdlib.h 这个版本,不能省略扩展名。

VC++ 自带头文件应使用 #include <stdlib.h> 这样的格式。