I want to write a program in C ++ that fills the lines of the two-dimensional array a and outputs this array line by line to the file output.txt . I use CodeBlocks. After starting the program, it does not stop, but is executed manually before the interruption, and the file "output.txt" quickly grows in size. When you open the file output.txt in Windows, the text editor does not respond. What's my mistake?
#include <fstream> using namespace std; int main() { ofstream out; out.open("output.txt"); int a[5][5]; for (int i; i<4; ++i) { for (int j; j<4; ++j) { a[i][j]=j; } } for (int i; i<4; ++i) { for (int j; j<4; ++j) { out<<a[i][j]; out<<' '; } } out.close(); return 0; }