This is my project:
Read the data one line at a time and store them in two different arrays.

Pass the first array to a function that sorts the array in ascending
order using selection sort.

Pass the second array to a function that sorts the array in descending
order using selection sort.

(Use your functions from the previous assignment to sort.)

Print each array before and after sorting.

my main problem is that im having much trouble reading the numbers from the .dat file and storing them in an array, any help you could give me would be great...thanks

void ascendingsort(int list[], int length)
{
        int index, smallestindex, minindex, temp;   
        for (index = 0; index < length - 1; index++)
        {
                smallestindex = index;
                for (minindex = index + 1;minindex < length; minindex++)
                        if (list[minindex] < list[smallindex])
                                smallestindex = minindex;

                temp = list[smallestindex];
                list[smallestindex] = list[index];
                list[index] = temp;
        }
}

void descendingsort(int list[], int length)
{
        int index, smallestindex, minindex, temp;   
        for (index = 0; index < length - 1; index++)
        {
                smallestindex = index;
                for (minindex = index + 1;minindex < length; minindex++)
                        if (list[minindex] > list[smallindex])
                                smallestindex = minindex;

                temp = list[smallestindex];
                list[smallestindex] = list[index];
                list[index] = temp;
        }
}

int main()
{
        double num1, num2, num3;
        ifstream fin; 
        ofstream fout;
        fin.open("scores.dat");
        fout.open("results", ios::trunc);

}

so what have you actually done to read the data?
You've declared the file, but that doesn't read the data...

Show some initiative first, try it yourself.

Oh, how about

fin >> some_array[whatever_index];

I think you can fill in the right names.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.