ARGH this is confusing
it still doesnt stop it if it has over 100 it just cuts it off and if it has 0 it crashes not mention i seems to equal 93 for some reason which is way at the beginning of the file
main:
Code:
bool exit = false;
double avg;
int smallest;
int count_abv = 0;
int count = 0;
int file_data[99];
ifstream in("onehundred.dat");
while(exit == false)
{
if(in.is_open())
{
count = load_array(in, file_data, 99);
in.close();
if(count == -1)
exit = true;
else
{
print_array(file_data,count);
avg = calc_average(count,file_data);
cout << avg << endl;
count_abv = count_abv_avg(file_data,count,avg);
smallest = smallest_number(file_data,count);
display(avg, count_abv);
exit = true;
load_array function
Code:
int load_array(ifstream& in, int file_data[], int arraysize)
{
int i = 0;
in >> file_data[i++];
try{
if(!file_data[i])
throw "File is Empty";
while( !in.eof())
in >> file_data[i++];
if(i >= arraysize)
throw "Too many elements error";
}
catch(const char* s)
{
cout << s << endl;
i = -1;
}
cout << "VALUE OF I\n" << i << endl;
return i;
}