c++读取写入文件(单个数据➕数组)简易框架

读取,写入文件
假设input1.txt文件里数据为
k(下列数组个数)k不大于100
a b c d e…
例如
5
343 23 452 19 27

#include iostream//改
#include fstream//改
using namespace std;

int main()
{
int a[100];
ifstream fp(“C:/Users/***/Desktop/input1.txt”);//读取文件
int k;
fp>>k;
for(int i=1;i<=k;i++)
fp>>a[i];
fp.close();

ofstream op(“C:/Users/***/Desktop/output1.txt”);//写入文件
op< for(int i=1;i<=k;i++)
op< op.close();
return 0;
}

你可能感兴趣的:(笔记)