I'm trying to get this simple c++ program to work but I keep bouncing from error to error.
Here's the code:
#include <iostream>
using namespace std;
const int row = 3;
const int col = 3;
int array[row][col];
void print(int array[row][col]){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
cout << array[i][j];
}
}
}
void setValues(int (&array), int value){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
array[i][j] = value; //invalid types 'int[int]' for array subscript
}
}
}
int main() {
setValues(array, 30); //Expected primary-expression before ',' token + Invalid Arguments 'Candidates are: void setValue(int &, int)
print(array); //expected primary=expression before ')' token
return 0;
}
I want to change values in a 2D array with a function.