i wrote a simple program(C++) that take 20 numbers and sort them into ascending order.Now i want to save the actions in the program in a file like "num.txt" with . Can you explain me what changes should i do?
#include <iostream> #include <iomanip> #include <conio.h> using namespace std; int main() { int x[21], s; int j,i; for (int i = 1; i < 21; i++) { cout << setw(11) << i << ": "; cin >> x[i]; } for (int i = 1; i < 21; i++) { for (int j = i+1; j < 21; j++) { if (x[j] < x[i]) { s = x[j]; x[j] = x[i]; x[i] = s; } } } cout << endl; for (int i = 1; i < 21; i++) { cout << i << ": "; cout << x[i] << "\t"; if (i % 5 == 0) { cout << endl; } } getch(); return 0; } i know it's simple but i just started since few days ago and i'm novice.