该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我的代码:
目的是传入一个任意大小的二位数组,然后打印出第一个项。
# include
void printFirst( int row, int col, int array[row][col])
{
printf("%i\n", array[0][0]);
}
int main (void)
{
void printFirst (int row, int col, int array[row][col]);
int test[3][5] = {
{1, 2, 3, 4, 5},
{4, 5, 6, 7, 8},
{7, 8, 9, 1, 3}
};
printFirst(3, 5, test);
return 0;
}
可是报错:
V:\Cynthia\03.c:3:46: error: use of parameter 'row' outside function body
V:\Cynthia\03.c:3:51: error: use of parameter 'col' outside function body
V:\Cynthia\03.c: In function 'void printFirst(...)':
V:\Cynthia\03.c:5:20: error: 'array' was not declared in this scope
V:\Cynthia\03.c: In function 'int main()':
V:\Cynthia\03.c:11:50: error: use of parameter 'row' outside function body
V:\Cynthia\03.c:11:55: error: use of parameter 'col' outside function body
请问是哪里出了问题?