У меня есть несколько строк по 5 разных значений в файле, и я хочу создать двумерный массив, используя этот файл, где каждый массив внутри основного массива имеет 5 значений, и я хочу добавить значения в массив доВ основном массиве существует 20 подмассивов, или достигнут конец файла
С моим кодом, однако, вообще не существует выходных данных, и я не знаю, что произошло
#include <iostream>
#include <fstream>
const int row = 20;
const int column = 5;
using namespace std;
int main()
{
double temperature[row][column];
double temp;
ifstream inFile;
inFile.open("grades1.txt");
if (inFile) //if the input file to be read open successfully then goes on
{
while (inFile >> temp) //reads through file
{ //adds answers to the array
// Inserting the values into the temperature array
for (int i = 0; i < row; i++)
{
for(int j = 0; j < column; j)
{
temperature[i][j] = temp;
}
}
}
for(int i=0; i<row; i++) //This loops on the rows.
{
for(int j=0; j<column; j++) //This loops on the columns
{
cout << temperature[i][j] << " ";
}
cout << endl;
}
}
}
Это файл температуры, который я использую
61.4 89.5 62.6 89.0 100.0
99.5 82.0 79.0 91.0 72.5
Если кто-нибудь сможет найти ошибку в моем коде, чтобы исправить ее, это будет очень полезно