小林るなruna在线观看:关于C++问题---IO流

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 05:18:49
不知?会出现
Cannot compile the file 'f:\test\222.h';no compile tool is associated with the file extension.

请高手指教

#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main()
{ fstream outfile;
outfile.open("f2.dat",ios::out);
if (! outfile)
{cout<<"f2.dat can't open.\n";
abort();
}
outfile<<"this is a program.\n";
outfile<<"this is a program.\n";
outfile.close();
}

程序编译应当无语法错误。

编译时,你的源程序名字用错了。
打成 'f:\test\222.h' 了,是吧。
源程序的扩展名应当是 .cpp

"Cannot compile the file 'f:\test\222.h';no compile tool is associated with the file extension." [无法编译'f:\test\222.h',因为没有编译工具与此扩展名对应]

把文件名后缀改成.cpp,重新载入再编译试试。