I am getting an error in the following program与PARAM所有功能(INT和,INT和)
#include<stdio.h>
void func(int &x,int &y){
}
int main(){
int a=10,b=6;
func(a,b);
return 0;
}
Error:
prog.c:2: error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token prog.c: In function ‘main’: prog.c:7: warning: implicit declaration of function ‘func’
but when I am changing function parameter type from (&) to (*) or any other type then it is working properly.
Like this:
#include<stdio.h>
void func(int *x,int *y){
}
int main(){
int a=10,b=6;
func(&a,&b);
return 0;
}
Thanks in advance.
Nks
这是正确的,C没有引用。作为克里斯说,你不能在c中使用引用(即&),因此可以使用 – chris
。 c只支持指针。没有参考。 – Arpit