c++讀取文件中的浮點數

#include<iostream>
#include<fstream>
using namespace std;
int main ()
{
	fstream infile("data.txt");
	double a = 0.0 ,b= 0.0,c = 0.0;

	if(!infile)
	{
		cout<<"Unable to open the file !";
		return 1;
	}
	infile>>a;
	infile>>b;
	infile>>c;
	cout<<a<<endl;
	cout<<b<<endl;
	cout<<c<<endl;
	return 0;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章