I have a little text file and I can read it into an array with the code below. I'd like to read them into a multi-dimensional vector (or vector of vectors if you will). Not many tutorials on multidimensional vectors. The don't understand the pushback, clear, popback commands. I've tried to do them to no avail.
This is NOT homework, just trying to teach myself the language.
My questions are: How can I read the elements into a multi dimensional-vector? and if you decide to write any code, could you please comment the vector commands so I can see how they are working?
Thank you very much, I appreciate it.
1 2 3 4 5 6 7 8 9 10 11
void readmap(){
int gamemap[12][10];
int rms;
ifstream thefile ("room.dat");
for (int y=0; y<12; y++){
for (int x=0;x<10;x++){thefile >> rms;
gamemap[y] [x]= rms;
}
}
thefile.close();
}
Thank you anup30, I was expecting a few for/next loops, but this works just fine, AND, you've given me something else to study on, that "auto" in your print loop.