写文件的问题
# include<iostream># include<fstream>
using namespace std;
void main(){
ofstream out;
out.open("grade",ios::out,filebuf::sh_compat);
out<<"C++"<<" "<<89.5<<endl;
out<<"English"<<" "<<93.5<<endl;
out<<"Maths"<<" "<<87<<endl;
out.close();
}
编译后:
Compiling...
FIO.CPP
F:\vc++\vc++程序\MyObject\FIOStreamObject\FIO.CPP(8) : error C2039: 'sh_compat' : is not a member of 'basic_filebuf<char,struct std::char_traits<char> >'
F:\vc++\vc++程序\MyObject\FIOStreamObject\FIO.CPP(8) : error C2065: 'sh_compat' : undeclared identifier
执行 cl.exe 时出错.
FIOStreamObject.exe - 1 error(s), 0 warning(s)
我查msdn的时候open()函数里面的确有三个参数也,怎么会出现这样的错误呢?