有一个含有8个元素的整数数组,从键盘输入8个整数给数组,并将此数组的数值存放到磁盘文件shuzu.dat中。
可参考:https://www.jb51.net/article/246257.htm
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int arr[8];
for(int i=0; i<8; i++)
{
cin>>arr[i];
}
ofstream ofs;
ofs.open("shuzu.dat", ios::out);
for(int i=0; i<8; i++)
{
ofs<<arr[i]<<endl;
}
ofs.close();
return 0;
}