On the 2nd for-loop, I get the following error from gcc:
error: expected unqualified-id before \'int\'
I\'m not sure what I\'m missing. I\
Try without the int
before col
.
for (int i = 0, col = 0; i < values.size(); i++, col++)
Others have already told you how to fix the problem you've noticed. On a rather different note, in this:
if (col > 10) { std::cout << std::endl; col == 0; }
It seems nearly certain that the last statement here: col==0;
is really intended to be col=0;
.
This should fix it
for (int i = 0, col = 0; i < values.size(); i++, col++) {
if (col > 10) { std::cout << std::endl; col == 0; }
std::endl << values[i] << ' ';
}
}
A variable definition goes like this
datatype variable_name[=init_value][,variable_name[=init_value]]*;
This is akin to a regular multiple variables declaration/initialization in one line using a comma operator. You can do this:
int a = 1, b = 2;
declaring 2 ints. But not this:
int a = 1, int b = 2; //ERROR
Don't declare int after comma use,
for (int i = 0,col = 0; i < values.size(); i++, col++) {
if (col > 10) { std::cout << std::endl; col == 0; }
std::endl << values[i] << ' ';
}
}