gpt4 book ai didi

c - 警告 : Expected ‘int **’ but argument is of type ‘int (*)[(sizetype)(n)]’

转载 作者:太空狗 更新时间:2023-10-29 17:18:25 26 4
gpt4 key购买 nike

<分区>

以下代码:

#include <stdio.h>

void printSpiral(int **M, int row1, int row2, int col1, int col2) {
if (!((row1 <= row2) && (col1 <= col2)))
return;
int i;
for (i = col1; i <= col2; i++)
printf("%d ", M[row1][i]);
for (i = row1; i <= row2; i++)
printf("%d ", M[i][col2]);
for (i = col2; i >= col1; i--)
printf("%d ",M[row2][i]);
for (i = row2; i >= row1; i--)
printf("%d ",M[i][col1]);
printSpiral(M,row1+1,row2-2,col1+1,col2-1);
}

int main() {
int n;
scanf("%d",&n);
int M[n][n];
int i, j;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
scanf("%d",&M[i][j]);
printSpiral(M,0,n-1,0,n-1);
return 0;
}

给出以下警告:

spiral.c: In function ‘main’:

spiral.c:26:3: warning: passing argument 1 of ‘printSpiral’ from incompatible pointer
type [enabled by default]
printSpiral(M,0,n-1,0,n-1);`

spiral.c:3:6: note: `expected ‘int **’ but argument is of type ‘int (*)[(sizetype)(n)]’`
void printSpiral(int **M, int row1, int row2, int col1, int col2) {

我第一次看到这个警告。什么意思?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com