I've tried many methods and this one is one of them:
void init_table(int _table[][MAX_COLUMNS]) {
for (int i = 0; i < MAX_COLUMNS; i ) {
for (int j = 0; j < MAX_ROWS; j ) {
_table[i][j] = -1;
}
}
}
I am just trying to figure out how to initialize my array with -1 rather than 0 it defaults to.
CodePudding user response:
If you need to fill by the same value, use std::fill:
std::fill(_table, _table MAX_ROWS*MAX_COLUMNS, -1);
Of course, if you use padding or other advanced techniques, you should take this into account and adjust your code, but this is more advanced topics and should be considered separately.