So I created a data file with the following integers in it:
2
4 2
-3 1
10 7
3 5
the first number is the dimension of my matrices and the rest represent two
2x2 matrices
|4 2 | |10 7 |
|-3 1| | 3 5 |
now I ask the user for the name of this input file that I created which is very simple. Then comes the troublesome stuff for me.
I want to read this data from the input file onto a multidimensional dynamic array of integers by using pointers and new.
Lastly I want to multiply the two matrices and print the result on the screen (which I have already figured out a loop for doing multiplying them w/out using pointers just simple arrays but I can't figure it out with pointers/streams).
Here is what I have gotten so far I need some suggestions/insight on where to go from here b/c I am stuck b/c i get so confused with how I should read the integers from my input file and incorporate that into a loop that multiplies the two matrices.
Thanks for reading.Code:#include <iostream> #include <fstream> #include <string> using namespace std; typedef int* IntArrayPtr; int main() { string infile; cout<<"Enter the input file: "; cin>>infile; ifstream in_stream; in_stream.open(infile.c_str()); if (in_stream.fail()) { cout<<"Input file "<< infile <<" opening failed.\n"; exit(1); } IntArrayPtr *m = new IntArrayPtr[2]; in_stream >> number; while (in_stream >> number) {