#include <iostream>
#include <fstream>

using namespace std;

double numbers[50];
size_t n=0;

void ReadDoubles(istream & f)
{
while(n<50)
{
f >> numbers[n];

if(f.eof())
break;

n++;
}
}

void PrintDoubles(ostream & q)
{
for(size_t k=0; k<n; k++)
q << numbers[k] << endl;
}

int main()
{

fstream f("test.txt", ios::in );

if(!f.good())
{
cerr << "Error opening file" << endl;
return -1;
}

ReadDoubles(f);
PrintDoubles(cout);

return 0;
}

Last modified: Saturday, 12 November 2011, 5:38 PM