I'm still very bad at working with files in CPP. I need to read the matrix (we assume that the dimension is known) from a text file. Here is my code:
#include "stdafx.h" #include <iostream> #include <fstream> using namespace std; int main() { ifstream matrix("C:\\Users\\Pavel\\Desktop\\cpp1\\matrix.txt"); float a[60][60]; for (int i = 0; i <= 60; i++) for (int j = 0; j <= 60; j++) matrix >> a[i][j]; for (int i = 0; i < 60; i++) for (int j = 0; i < 60; i++) cout << a[i][j] << " "; system("Pause"); return 0; } The problem is that the program reads only the first number from the file and writes it to only (!) The first line of my array. When outputting, the program produces only this first line with the same number. How can I write the entire file to an array, and then output it without problems?