fstream.h中已经包含iostream.h了,为什么...

local local 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

#include <fstream>
using namespace std;
int main()
{
int a[10];
ofstream outfile;
outfile.open("student.txt",ios::app);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
cout<<"enter 10 integer numbers:"<<endl;
for(int i=0;i<10;i++)
{
cin>>a[i];
outfile<<a[i]<<" ";
}
outfile.close();
return 0;
}

fstream.h中已经包含iostream.h了,为什么还提示错误:
'cerr' : undeclared identifier
'cout' : undeclared identifier
...
加上#include <iostream>就对了。
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
local
C++ 语言 65,214 成员 250,514 内容