C++如何逐行读取txt文件,并将读取出来的数据进行运算导入到另一个文件中。

如题所述

第1个回答  2022-11-16

intmain()

{

inta[16]={0};

FILE*fp=fopen("aa.txt","r");

inti=0;

while(!feof(fp))

{

fscanf(fp,"%d",&a[i]);

i++;

}

return0;

}

扩展资料

在Python一次性读取数据

file='novel.txt'

withopen(file)asfile_object:

contents=file_object.read()

print(contents)

运行结果:

Itisatruthuniversallyacknowledged,thatasinglemaninpossessionofagoodfortune,mustbeinwantofawife.