Question: C++ Please help me with this sorting problem. If more info is needed please comment and let me know. The sorting portion is commented out.

C++ Please help me with this sorting problem. If more info is needed please comment and let me know. The sorting portion is commented out.

#include

#include #include #include #include #include #include

using namespace std;

int main() {

//decalre variabe

string input;

string line;

//declare array to store int col values

int col1[1000];

//declare arrays to store the string column values

string col2[1000], col3[1000], col4[1000];

int lineno = 0;

cout << "Enter in your text file name or type 'done' to end the program:" << endl;

cin >> input;

//read inpupt unitll user input done

while (strcmp(input.c_str(), "done") != 0)

{

//Read file

ifstream myfile(input.c_str());

if (myfile.is_open())

{

//lineno variabel to add row to index lineno in the array

lineno = 0;

while (getline(myfile, line))

{

//split the line and read into variable below

istringstream ss(line);

int c1;

string c2, c3, c4;

ss >> c1 >> c2 >> c3 >> c4;

//store the values in the array

col1[lineno] = c1;

col2[lineno] = c2;

col3[lineno] = c3;

col4[lineno] = c4;

lineno += 1; /*//FixMe Sorting for (i = 0; i

//sorting the different cards if (col1[j]>col1[j + 1]) { temp1 = col1[j]; col1[j] = col2[j + 1]; col1[j + 1] = temp1; if (strcmp(col2[j - 1], col2[j]) < 0)

strcpy(temp2, col2[j]); strcpy(col2[j], col2[j + 1]); strcpy(col2[j + 1], temp2);

strcpy(temp3, col3[j]); strcpy(col3[j], col3[j + 1]); strcpy(col3[j + 1], temp3);

strcpy(temp4, col4[j]); strcpy(col4[j], col4[j + 1]); strcpy(col4[j + 1], temp4);

}//if

}//for j

}//for i } */ myfile.close(); //printing 3 groups in each line

for (int i = 0; i

cout << " ";

}//for

}

else

cout << "Unable to open file";

cout << "Enter in your text file name or type 'done' to end the program:" << endl;

cin >> input;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!