N
none
I have a .txt file containing strings ordered as a row*column matrix, eg.:
a basd asdasd asdasd ada asdasd asdda
b basd asdasd asdasd ada asdasd asdda
c basd asdasd asdasd ada asdasd asdda
c basd asdasd asdasd ada asdasd asdda
The number of columns for each row is constant. I am trying to write a function that given a txt
file as the one above returns the i,j element like:
std::string file = "c:\test.txt";
int rows = numberOfRows(file);
int columns = numberOfColumns(file);
for (int i=0; i<rows; i++) {
for (int j=0; j<columns; j++) {
std::string elem = readCell(i,j,file);
}
}
Any hints on a smart version of readCell are welcome since my current version is pretty ugly...maybe
there are some build in functionality for this kind of txt file parsing that I have missed ?
a basd asdasd asdasd ada asdasd asdda
b basd asdasd asdasd ada asdasd asdda
c basd asdasd asdasd ada asdasd asdda
c basd asdasd asdasd ada asdasd asdda
The number of columns for each row is constant. I am trying to write a function that given a txt
file as the one above returns the i,j element like:
std::string file = "c:\test.txt";
int rows = numberOfRows(file);
int columns = numberOfColumns(file);
for (int i=0; i<rows; i++) {
for (int j=0; j<columns; j++) {
std::string elem = readCell(i,j,file);
}
}
Any hints on a smart version of readCell are welcome since my current version is pretty ugly...maybe
there are some build in functionality for this kind of txt file parsing that I have missed ?