<分区>
这是我的代码,但我得到第一个数字的无限循环
我想从文件中读取整数并将它们存储在数组中
文件包含:
8 5 12 1 2 7
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
int n = 0; //n is the number of the integers in the file ==> 12
int num;
int arr[100];
ifstream File;
File.open("integers.txt");
while(!File.eof())
{
File >> arr[n];
n++;
}
File.close();
for(int i=0;i<12;n++)
{
cout << arr[i] << " ";
}
cout << "done\n";
return 0;
}
请帮忙