Taking your code to the 21st century, and doing correct indentation (which helps understanding the code), we get:
#include <fstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <conio.h>
using namespace std;
int amountRead = 0,max_read = 99;
const int maxn = 4200;
float array[maxn] = {0.00000};
void getfloat();
void read();
float sort();
float sort()
{
// you could also use the standard sort function:
//sort( array, array + amountRead, greater<float>() );
for(int i=0;i<amountRead;i++) //prefer declaring 'i' in the for-loop.
for(int j=0;j<amountRead-i;j++) //prefer declaring 'j' in the for-loop.
if(array[j]<array[j+1])
swap(array[j], array[j+1]
amountRead++; //what is this?
ofstream outfile("sort2.txt"); //don't do open-close at each iteration.
for(int i = 0; i < amountRead; ++i)
{
//if(array[i] != 0) //this comparison is useless of 'float' variables, they are rarely exactly 0.
//{
cout << array[i] << endl;
outfile << array[i] << endl;
//}
}
//Where is the return value???
}
void getfloat()
{
ifstream infile("sort2.txt"); //declare variables when you use them first.
ofstream outfile("sort3.txt"); //don't open-close the file for no reason.
float x = 0.0; //prefer local variables, try to avoid global variables when unnecessary.
while(infile >> x) //check the input at the same time as reading.
outfile << x << endl;
}
int main() //the C++ standard requires that main() returns an integer.
{
ifstream infile("float.txt");
while((amountRead < max_read) && (infile >> array[amountRead])) //invert the conditions to use the "short-cut" feature of '&&'.
++amountRead; //pre-increment is preferred in general.
for(int i = 0; i < amountRead; ++i)
cout << array[i] << endl;
sort(); …