我正在尝试编写一个函数来交换二维数组中的 2 个元素:
void swap(int surface[][], int x1, int y1, int x2, int y2) {
int temp = surface[x1][y1];
surface[x1][y1] = surface[x2][y2];
surface[x2][y2] = temp;
}
但是,当我尝试编译它(gcc)时,我收到以下错误消息:
Sim_Annealing.c: In function `swap':
Sim_Annealing.c:7: error: invalid use of array with unspecified bounds
Sim_Annealing.c:8: error: invalid use of array with unspecified bounds
Sim_Annealing.c:8: error: invalid use of array with unspecified bounds
Sim_Annealing.c:9: error: invalid use of array with unspecified bounds
为了将二维数组作为函数参数,我需要做一些特殊的事情吗?
谢谢你的帮助。如果您知道数组作为函数参数的任何好的参考资料,请按我的方式发送:)