Hi there, hopefully my this simple program will help you out........Actually it is almost as same as your's but i did lots of changes. The word in magenta , i think is ofstream instead of ifstream. :mrgreen:
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <fstream>
using namespace std;
void readStoreCount();
void printNumbers();
int main ()
{
readStoreCount();
printNumbers();
return 0;
} //main
void readStoreCount()
{
int i = 0;
float numbers[100];
ofstream source;
source.open ("source.txt");
if (!source)
{
cerr << "\aError 100 opening source.txt" << endl;
exit (1); // Exit Program If The File Cannot Be Opened //
}
for (i = 0; i < 100; i++)
{
numbers[i]=i;
source<<numbers[i]<<endl; // Intializing The numbers Into Your Source File //
}
cout << "Numbers are going in the file............. " << endl;
cin.ignore();
system("cls");
source.close ();
if (source.fail())
{
cerr << "\aERROR 102 closing source.txt" << endl;
exit (1); //closing failure test
}
}
void printNumbers()
{
int i=0;
ifstream source("source.txt",ios::in);
source.clear();
source.seekg(0);
float Num;
float numbersIn[100];
while(i<100 && !source.eof() ) // Input The Numbers from The File Into The Array NumbersIn[]
{ // While i<100 And While File Is Not End Of File.
source>>Num;
numbersIn[i]=Num;
i++;
}
source.close();
cout<<"The Numbers Taken From The File Are :- "<<endl;
cout<<"======================================="<<endl;
for(int j=100; j>=0; j--) // Display The Numbers in The Array From Largest
{ //numbersIn[100] To numbersIn[0] //
cout<<numbersIn[j]<<endl;
}
cout<<endl;
}