Sorting through data in descending order

I have a problem with my code...
First of all, is there a way (in very basic fstream) to store values in a dataset directly to an array that I can display in multiple places in the file?
Second of all, My function calls are bringing up errors...I don't know why...could someone help me out and offer suggestions?
Lastly, the code is supposed to sort through a dataset and then display the values in descending order. Am I on the right track? Please offer suggestions to make it better please. Thank you for those who respond in advance!!!!!

Here is my code so far:

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int MAX_ARRAY_SIZE = 100;

void exchange_sort(int array[], int array_size);
float median(int array[], int array_size);

int main()
{
ifstream infile;
int count = 0, number[MAX_ARRAY_SIZE], next, array;

infile.open("numbers.dat");
if (infile.fail())
{
cout << "Failed to open file." << endl;
exit(1);
}

cout << "The original array: " << endl;
while (infile >> next)
{
cout << next << " ";
cout << " ";
count += 1;
}

cout << endl << "The sorted array (from high to low): " << endl;
exchange_sort(array, count);

cout << endl << "The median of the dataset is: " << endl;
float median(array, count);
return 0;
}

void exchange_sort(int array[], int array_size)
{
ifstream infile;
int i, j, next, num;
int temp;

for (num = 0; num <= MAX_ARRAY_SIZE; num++)
{
while (infile >> next)
{
if (i >= j)
return;
else
{
temp = i;
i = j;
j = temp;
}
}
}
}

float median(int array[], int array_size)
{
return 0;
}
Topic archived. No new replies allowed.