Hello guys,
Firstly I want to apologize If I ask something silly, but I have just started learning C++, and I really don't know much.
As a practice I have a challenge of writing a matrix in a file, and then reading the information (numbers) from it, and in the end to be able to do some calculations, for example to multiply the positive members of that matrix.
So far I have only managed to write a matrix in a file by using this code:
-------
int main()
{
const int m=4, n=5;
int i,j;
int A[m][n]={{5,3,-4,8,2},
{1,5,2,7,-8},
{-3,9,5,2,4},
{4,-1,3,6,8}};
ofstream Write("c:/matrix/matrix.txt", ios::out);
for (i=0;i<m;i++)
{
For (j=0;j<n;j++)
Write << setw(3)
<< A[j] ;
Write << "n";
}
return 0;
}
--------------
Now the next thing i want to do, is to make some calculations with specific members of the matrix, say multiply the negative members or something like this.
I'm trying to use the "ifstream Read("c:/matrix/matrix.txt", ios::in)" to open the file for reading, but I can't figure it out how to achieve the above goal.
Can someone show me an example of how I might achieve this?
Thanks in advance for any kind of help.