例子:
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int array[2][8]={{1,4,5,77,99,6,55,3},
{21,3,54,6,7,88,55,44}
};
int main()
{
ofstream os("d:\\dt\\data.txt",ios::app);
if (os)
{
for (int i=0;i<2;++i)
{
for (int j=0;j<8;++j)
os<< array[i][j]<<" ";
os<<endl;
}
}
else
cerr<<"无法打开文件!"<<endl;
return 0;
}