I've a program that reads from an input file an unknown amount of integers from a matrix and places them into a 2D vector. Once I have those integers inside the 2D vector I will output to another file each integers matching ASCII character. My problem is i was able to find a working double for loop that prints out 2D vectors but i'm unsure as to how the range inside the for loops work.
while(getline(in, row)){
int num;
stringstream ss(row);
vector<int> vR;
while(ss >> num){
vR.push_back(num);
}
vMain.push_back(vR);
}
for(auto vR : vMain ){ //<------Here
for(auto num : vR){ //<------Here
if(num >= 0 && num <= 14){
cout << " ";
out << " ";
}
.
.
.
}
I created the while loop to take in the values of the file using a stringstream, then pushing back each row vector "vR" inside the main vector "vMain".
The for loops go through the vectors one value at a time then output the corresponding ASCII value, how exactly does the " : " range-based for loops work?