Inputting a dynamic array into a .txt file and outputting a sorted dynamic array?

Hi guys,

I have this assignment due for a beginner Computer Science class. I understand the concept of making a .txt file and I also understand how to create an array and sorting by descending or ascending. However, I do not understand the concept of inputting the numbers in the input.txt file, writing a or d to specify the order, and having an output.txt file come up and rearrange the order of the array. Can someone please clear this up for me?

Also, sorry for my bad English. It is not my main language.
Last edited on
However, I do not understand the concept of inputting the numbers in the input.txt file
You are asked to read input from a files. After you set everything up, ifstream works just like cin: http://www.cplusplus.com/doc/tutorial/files/

writing a or d to specify the order
1
2
3
4
5
6
char c;
std::cin >> c;
if (c == 'a')
    //Sort ascending
else if (c == 'd')
    //Sort descending 


having an output.txt file come up and rearrange the order of the array
You are asked to output sorted array into file. After you set everything up, ofstream works just like cout: http://www.cplusplus.com/doc/tutorial/files/
Topic archived. No new replies allowed.