如图,题主想把一个二维数组传入名为convert的函数中,但vscode就是硬要说函数头有问题😫:
终端面板内容:
> Executing task: C/C++: g++.exe 生成活动文件 <
正在启动生成...
F:\MinGW\bin\g++.exe -fdiagnostics-color=always -g E:\acc\lights.c -o E:\acc\lights.exe
E:\acc\lights.c:6:32: error: use of parameter outside function body before ']' token
void convert(int m, bool (*a)[m], int t)
^
E:\acc\lights.c:6:33: error: expected ')' before ',' token
void convert(int m, bool (*a)[m], int t)
^
E:\acc\lights.c:6:35: error: expected unqualified-id before 'int'
void convert(int m, bool (*a)[m], int t)
^~~
生成已完成,但出现错误。
终端将被任务重用,按任意键关闭。
错误面板内容:
当把一个二维数组作为一个函数参数时,你可以省略第二维大小,但是第一维的大小必须是常数。例如
void f1(int a[][5], int n) { // 等价于 void f1(int (*a)[5]),其中第一个维大小必须是常数
// ...
}
int main()
{
int array[3][5];
f1(array, 3);
}
[m]改为[],把m去掉