Question: #include #include using namespace std; const unsigned int R_SIZE = 4; const unsigned int C_SIZE = 5; void readArray(int twoDArray[][], string inFile); // function prototype
#include
const unsigned int R_SIZE = 4; const unsigned int C_SIZE = 5;
void readArray(int twoDArray[][], string inFile); // function prototype
int main() { int i, j; int array1[C_SIZE][R_SIZE]; string fileName;
// prompt user for input cout << "Please enter the name of the file containing data for Array 1: "; cin >> fileName; readArray(array1[][],fileName); for (i = 0; i < C_SIZE; i++) { for (j = 0; j < R_SIZE; j++) { cout << array1[i][j] << " "; } cout << endl; }
return 0;
}
/* Function: readArray Purpose: To read values into an array. Parameters: Base address of an array. Returns: void -----------------------------------------------------------*/ void readArray(int twoDArray[][C_SIZE], string inFile) {
ifstream inpF; int i, j;
inpF.open(inFile);
for (i = 0; i < R_SIZE; i++) { for (j = 0; j < C_SIZE; i++) { inpF >> array1[i][j]; } }
inpF.close();
} // end readArray function
complete the code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
