I'm supposed to read a text file of unsorted numbers, sort them, and then write them to an output file. But when I open the file that I wrote to, the only thing on it is a bunch of zeros.
int main()
{
unsigned int size = 10000000;
ifstream inFile("numbers.txt");
inFile >> size;
unsigned int * nums = new unsigned int[size];
for (int i = 0; i < size; i++)
{
inFile >> nums[i];
//cout << "number " << i << ": " << nums[i] << endl;
}
inFile.close();
Sort obj(size);
Merge obj2(size);
Heap obj3(size);
Quick obj4(size);
clock_t startTime, endTime;
startTime = clock();
//obj4.quickSort(nums, 0, size-1);
//obj3.heapSort(nums, size);
obj2.mergeSort(nums, 0, size - 1);
//obj.selectionSort(nums, size);
endTime = clock();
ofstream outFile("numbersNew.txt");
for(int i = 0; i < size; i++)
{
outFile << nums[i] << endl;
}
outFile.close();
cout << "Sort took: " << endTime - startTime << " milliseconds" << endl;
//
// //for (int i = 0; i < size; i++)
// // cout << nums[i] << endl;
return 0;
}
Here is the rest of my code:
https://pastebin.com/rY8QxsJy