Question: C++ I currently have code that prints and organizes an array that is needed into console. How do I transfer that to a .txt file?

C++ I currently have code that prints and organizes an array that is needed into console. How do I transfer that to a .txt file?

the top part is the organization of it and the bottom is printing the organized list into console:

for (i = 0; i < amount; ++i) { // organize the list for (j = 1; j < amount; ++j) { if (city[j - 1] > city[j]) { //testing to see which one starts first temp = city[j - 1]; city[j - 1] = city[j]; city[j] = temp; //finished with one and going back up to finish } } }

// print array elements using while loop i = 0; cout << "List of city names: " << endl;

while (i < amount) { cout << city[i] << " "; // print organized list i++; }

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!