Hello,
I've checked google now intermidintly for two days, and I could not find a solution for my problem, so I decided I would post my own thread on here.
The program I'm designing is supposed to ask the user for a file name, open that file, then take the average and find the least and greatest. My problem is, my program is getting stuck just accepting data from a file, and I'm not sure why. It never even gets to any of my functions.
Here's some of my code:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void Average(double NumbersFromFile[50], int);
void Least(double NumbersFromFile[50], int);
void Greatest(double NumbersFromFile[50], int);
int main()
{
int Counter=0;
double NumbersFromFile[50]={0};
char FileName[50]={0};
cout << "What is the name of you file?" << endl;
cin >> FileName;
ifstream InputFile;
InputFile.open(FileName);
if(InputFile)
{
cout << "Error!";
return 0;
}
while(!InputFile.eof())
{
InputFile >> NumbersFromFile[Counter];
Counter++;
}
InputFile.close();
Least(NumbersFromFile, Counter);
Greatest(NumbersFromFile, Counter);
Average(NumbersFromFile, Counter);
return 0;
}
Any help would be greatly appreciated.