Pleased I need help to read-in an ASCII file into a 2-dimensional integer array. I also want to automatically extract the number of columns and rows from the buffer. I am not getting something right for sure.
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main() {
int row = 0, col = 0, numrows = 0, numcols = 0;
ifstream askeeFile ("asciiFile.dat");
stringstream sd;
int array[numrows][numcols]; //2-Dimensional array
sd << askeeFile.rdbuf();
sd >> numcols >> numrows; // I need to know the number of rows and columnn here
//Populating the 2-D array with the file content
for(row = 0; row < numrows; ++row){
for (col = 0; col < numcols; ++col){ sd >> array[row][col];
askeeFile >> array[row][col];
cout << array[row][col];
}
}
askeeFile.close();
return 0;
}