I'm basically trying to get this to read in a file called something like foo.dat using at the command line ./foo foo.dat foo.txt, where ./foo is the compiled program, foo.dat is the input file, and foo.txt is the output file. I'm trying to read the doubles from foo.dat and sort them using selection sort, and also print the results and store them in a file called foo.txt. I'll be honest some of this code probably makes no sense becuase i'm not too sure on what i'm doing, but if you can provide me any help at all I appreciate it.
Code:
#include <iostream> 
#include <fstream>
#include <iomanip>
#include <string>
#include <cctype> 
using namespace std;

const int MAXSIZE = 56; 

void selectionSort(int arr[], int size); 
void swap(int& x, int& y); 

int main(int argc, char *argv[]) 
{ 
  const int MAXSIZE = 56;
  int numbers[MAXSIZE] = {0}; 
  int k; 
  int ImANumber;
  char ch;

ifstream fin(argv[1]);
ofstream fout(argv[2]);
 fin >> ImANumber;
 

cout << endl << "BEFORE SORT: "; 
for (k = 0; k < MAXSIZE; k++) 
  cout << numbers[k] << endl; 
    
selectionSort(numbers, MAXSIZE); 

cout << endl << endl; 
cout << "AFTER SORT: "; 
for (k = 0; k < MAXSIZE; k++) 
  cout << numbers[k] << " "; 
  
cout << endl << endl << endl;  

 fin.close();
 fout.close();
return 0;
 
}// end main() 

void selectionSort(int arr[], int size)
{ 
  int indexOfMin, pass, j; 
  
  for (pass = 0; pass < size - 1; pass++) 
    { 
      indexOfMin = pass; 
      
      for (j = pass + 1; j < size; j++) 
	if (arr[j] < arr[indexOfMin]) 
	  indexOfMin = j; 
      
      swap(arr[pass], arr[indexOfMin]); 
    } 
}// end selectionSort() 

void swap(int& x, int& y) 
{ 
  int temp; 
  temp = x; 
  x = y; 
  y = temp; 
}// end swap()