Background:
I'm attempting to read through a 2d array and find values that coincide with row numbers and column numbers.
Question:
How do I read values off a file and acquire, for example, 1 and 4 vs. 14?
Here's what I have so far...
All constructive criticism is welcome.
int arrayOfNum[5][5] = {
{34,21,32,41,25},
{14,42,43,14,31},
{54,45,52,42,23},
{33,15,51,31,35},
{21,52,33,13,23}};
ofstream arrayFile;
arrayFile.open("arrays.txt");
if (arrayFile.is_open()) {
cout << "File opened successfully..." << endl;
}
for (int i = 0; i <= 4; i++) {
arrayFile << endl;
for (int j = 0; j <= 4; j++) {
arrayFile << arrayOfNum[j][i] << ' ';
}
}
std::ifstream, you may useoperator >>...<<for writing, what do you think you would use for operator to read from an input file stream? Hint: If you have usedstd::cinanytime you already know how to do it.