c++中如何将文件中的特定数据提取并重新赋值于数组?

2025-04-05 02:55:53
推荐回答(1个)
回答1:

建议用下面语句创建1.txt文件:

ofstream fout("1.txt");           
for(j = 0;j <= i;j++)
    fout << 

每个数据间用空格隔开。读出时,格式与“写”类似:

ifstream fin("1.txt");           
for(j = 0;j <= i;j++)
    fin >> name[j] >> round[j] >> countright[j] >> score[j] >> etime[j];

原来的空格作为分隔符,fin语句中不需要显式给出。