不兼容的指针类型,应为 float * 但参数的类型为 float (*)[2]

Incompatible pointer type, expected float * but argument is of type float (*)[2]

#define N 5
#define Nv 2

float Cities[N][Nv]={ {0,1}, {3,4}, {1,2}, {5,1} ,{8,9}};
void PrintVec2(float *a, int n) {   
   
    int i;
    for (i = 0; i < (n / 2); i++) printf("\n%f %f", a[2 * i], a[2 * i + 1]);
    printf("\n");
}

//somewhere I call this
PrintVec2(Cities,N*Nv);

New*Nv 是一个数字,整数。如何修复此警告?

原型:

void PrintVec2(float *a, int n)

与输入参数不匹配:

PrintVec2(Cities,N*Nv);

函数原型正在寻找数组的地址。将其更改为发送 &Cities[0][0]:

PrintVec2(&Cities[0][0],N*Nv);