Can somebody please help fix this code?
#include <iostream>
using namespace std;
int[][] setElem(int[][] arr, int xpos, int ypos, int val){
arr[ypos][xpos] = val;
return arr;
}
int main() {
int width;
int height;
cout << "Please enter the width of your terminal!" << endl;
// TODO: Verify user input
cin >> width;
cout << "Please enter the height of your terminal!" << endl;
cin >> height;
int frame[height][width];
for (int y = 0; y < sizeof(frame) / sizeof(frame[0]); y++){
for (int x = 0; x < sizeof(frame[y]) / sizeof(frame[y][0]); x++){
frame[y][x] = 0;
}
}
for (int y = 0; y < sizeof(frame) / sizeof(frame[0]); y++){
for (int x = 0; x < sizeof(frame[y]) / sizeof(frame[y][0]); x++){
cout << frame[y][x] << " ";
}
cout << endl;
}
frame = setElem(frame, 0, 0, 1);
cout << "New array!" << endl;
for (int y = 0; y < sizeof(frame) / sizeof(frame[0]); y++){
for (int x = 0; x < sizeof(frame[y]) / sizeof(frame[y][0]); x++){
cout << frame[y][x] << " ";
}
cout << endl;
}
}
Here are the errors
easy.cpp:5:4: error: structured binding declaration cannot have type ‘int’
5 | int[][] setElem(int[][] arr, int xpos, int ypos, int val){
| ^~
easy.cpp:5:4: note: type must be cv-qualified ‘auto’ or reference to cv-qualified ‘auto’
easy.cpp:5:4: error: empty structured binding declaration
easy.cpp:5:6: error: expected initializer before ‘[’ token
5 | int[][] setElem(int[][] arr, int xpos, int ypos, int val){
| ^
easy.cpp: In function ‘int main()’:
easy.cpp:31:13: error: ‘setElem’ was not declared in this scope
31 | frame = setElem(frame, 0, 0, 1);
| ^~~~~~~