I have a file with a list of names.

Jane Huston
Bob Brown
Jack Tracy

they should be ordered by last line

like this

Bob Brown
Jane Huston
Jack Tracy

but my program wont compile and i dont know how to fix it?

here is my code

#include <iostream>
#include <fstream>
using namespace std;

const int SIZE = 10;
const int MAXNAME = 20;

int FindSmallest (char array1, int start, int size)
{    int position = start;
     char smallest = array1[start]; // first assumption
     for (int k=start+1; k<size; k++)
    if (array1[k] < smallest)
    {    smallest = array1[k];  // change your mind
         position = k;      // and remember pos.
    }
     return position;
}


void Swap (char array1, int j, int k)
{    char temp;
     temp = array1[j];
     array1[j] = array1[k];
     array1[k] = temp;
}


void SelectionSort (char array1[SIZE][MAXNAME], char array2[SIZE][MAXNAME], int size)
{    int smallest_position;
     for (int n=0; n<size-1; n++)
     {  smallest_position = FindSmallest (array1[SIZE][MAXNAME], n, size);
    Swap (array1[SIZE][MAXNAME], n, smallest_position);
    Swap (array2[SIZE][MAXNAME], n, smallest_position);
    }
}




int main()
{
    char array1[SIZE][MAXNAME], array2[SIZE][MAXNAME];
    ifstream fin;
    ofstream fout;

    fin.open("h:\\file.txt");

    for (int n = 0; n<10; n++)
    {
        fin >> array1[n] >> array2[n];
    }
    fout.open("h:\\file_sorted.txt");
    SelectionSort (array1, array2, SIZE);

    for (int m = 0; m < 10; m++)
    {
        fout << array1[m] << " " << array2[m] << endl;


    }




    cout << "Now sorting" << endl;
    cout << "Done" << endl << endl;




    return 0;
}

Please re-post with code tags and formatting.

[code]

// paste code here

[/code]

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.