Question
Language is C++ I have a code written that is meant to read a matrix text file and display it in rows and columns. The
Language is C++
I have a code written that is meant to read a matrix text file and display it in rows and columns. The program will read the first line of the text file which will be the dimensions of the matrix. For example:
Matrix.txt
4 8
23 54 56 6 34 65 76 87
45 78 34 23 5 78 15 43
78 32 54 3 54 15 45 34
7 6 98 34 78 3 78 23
What program should output:
23 54 56 6 34 65 76 87
45 78 34 23 5 78 15 43
78 32 54 3 54 15 45 34
7 6 98 34 78 3 78 23
My Code:
#include
int** theTable;
int main() {
int numRows = 10; int numCols = 20;
int** theTable = new int* [numRows];
string fileName; cout
ifstream fin; fin.open(fileName); if (!fin) { cout
for (int i = 0; i
for (int r = 0; r > theTable[r][c]; cout
fin.close(); }
What my program is outputting;
Code Requirements:
I don't understand what I am doing wrong, so any help would be greatly appreciated
135456634657687457834235781543783254354154534769834783782300000000000000000000000000000000000000000000000000000000000000 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ress any key to close this window ... Now write a program that performs the following tasks: - Prompt the user for a file name - Accept that file name - Open the file for input (and exit if the file is not found) - Read the data in the file - Display the data as a table, in nice neat rows and columns Everything you need to know is here and in the previous demStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started