How to read a line of numeric data, put in an array to sort it with quick sort?
Iâm a noob in c++ so I might make a lot of flaws here. Ok, so I have a text file called ânumbersâ. It has the following data: 0 1 34 67 89 2 23 4 5 Based on a code from a cpp tutorial, I was able to read the file and print it: #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ifstream myfile ("numbers.txt"); if (myfile.is_open()) { while ( getline (myfile,line) ) { cout << line << '\n'; } myfile.close(); } else cout << "Unable to open file"; return 0; } Good, so now I desire to use a quick sort (Iâm prohibited to use bubble sort in this exercise) to print the numbers in ascending order. The problem behind it is that, for it to work, I need to put each data from the line into an array for it to be sortable. Based on the reading file code, how can I put each data in an array so that I can sort it? Iâve read some resources online but they use a lot of âstd::â which doesnât seem similar to the reading file code that Iâm using.