函数交换完成了工作,它交换成功,但我收到警告,但我不知道为什么。
void swap(char **a,char **b) {
char * temp = *a;
*a=*b;
*b=temp;
}
void function() {
char ** arr[max]; // this is an array of pointers of pointers
.....
swap(&arr[0],&arr[1]);
}
警告:从不兼容的指针类型传递“交换”的参数 1 警告:从不兼容的指针类型传递“交换”的参数 2
最佳答案
arr[0]
是指向指针 (char**
) 的指针。 &arr[0]
是一个指向指针的指针 (char***
),但您的函数需要 char**
。
更正的功能:
void swap(char ***a,char ***b) {
char **temp = *a;
*a=*b;
*b=temp;
}
关于c - C 中的交换指针 - 不兼容警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41491813/