When I'm reading from a file it adds one space at the end. So after, when I need to sort the string, it sorts the extra space too. And is added to the output file.
int main()
{
    int siz=1000000;
    char a[siz];
    ifstream readfile("AllAlpha.txt");
    ofstream outfile("sorted.txt");
    if(!readfile)
    {
        cout << "An error occurred while opening the input data stream file \"AllAlpha.txt\"!" << endl;
        return 1;
    }
    // read file
    int i=0;
    while (!readfile.eof())
    {
        readfile.get(a[i]);
        i++;
    }
    int size=i;
    // sort the array
    //quicksort(a, 0, size-1);
    // output sorted array to file
    for (int num=0;num<size;num++)
    {
        outfile<<a[num];
    }
    return 0;
}
 
    