C++ txt文件中的数据读入数组

#include <iostream>
#include <fstream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	float arr[100000]={0};
	ifstream infile("D://1.txt");
	int count = 0;
	while(!infile.eof())
	{
		infile>>arr[count];
		++count;
	}
	infile.close();

	for ( int j= 0; j < count; ++j)
		cout<<arr[j]<<endl;
	
	return 0;
}

你可能感兴趣的:(C++,数组,txt,文件)