Hello,
I am trying to put on a file a multi-dimensional matrix
something like the code below.
I can write and read a vector ou a uni-dimensional matrix to file but i've been struggling to do a multidimensional matrix.
May be i'm using a bad aproach, but i'm a beginner and all the help and advice is always welcome.
Thanks in advance.
#include <iostream>
#include <fstream>
using namespace std;
main()
{
char matriz[5][5];
for(int a=0;a<5;a++){
for(int b=0;a<5;b++)
matriz[a][b]='a';
}
ofstream fo("c:\\file.txt");
for(int a=0;a<5;a++){
for(int b=0;a<5;b++)
fo << matriz[a][b];
}
fo.close();
ifstream fi("c:\\file.txt");
char ch;
while(fi.get(ch))
cout.put(ch);
fi.close();
system("pause");
}