用以下代码试一下:
#include
#include
using namespace std;
#include
int main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
ofstream fout("G:\\fuck.txt",ios::out);
if ( fout.fail() )
{
cout << "open file error\n";
cout <<"errno: " <
}
/*
for(int i=0;i<10;i++)
fout< fout.close();
*/
return 0;
}