I am getting an error in the following program
#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 代码,您将收到编译器错误。 (int &x,int &y)
没有任何意义,看起来您正在尝试在 C 中使用 C++ 引用。
关于c - 使用参数 (int&, int&) 隐式声明所有函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14230325/