Hello, I was wondering how would the code below into QT
/*
content a MATRIX.txt
1 2 3
4 5 6
7 8 9 */
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
// declaring a POINTER FOR MATRIX to be dynamically allocated
char **m;
//char matriz[3][5];
//by declaring file handle variable to a txt file
ifstream txtFile;
int l,c,i,j;
//READ FILE.txt
txtFile.open("MATRIX.txt");
//read that LINE e COLUMN the matrix ;
txtFile >> l >> c;
//allocate a memory for matrix
m = (char **) malloc( l * sizeof(char *) );
for(int nl=0;nl<l;nl++){
m[nl]=(char *) malloc(c*sizeof(char *));
}
//open content a FILE.txt
for ( i=0; i<l; i++)
{
for(j=0; j<c; j++)
{
txtFile >> m[i][j];
}
}
cout << "the Matrix read file have LINE and COLUMN: \t " << l<< "X" <<c;
cout << "\n content of the matrix in the file: "<<endl;
for (int i=0;i<l;i++)
{
for(int j=0;j<c;j++)
{
cout << m[i][j];
}
printf("\n");
}
//fecha arquvivo
txtFile.close();
system("pause");
}
Bookmarks