c - 使用参数 (int&, int&) 隐式声明所有函数

标签 c function compiler-errors

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/

相关文章:

c - 数据包中的字符串搜索并打印数据包数据

Javascript 方法调用和打印

Jquery变量在函数中的使用

gcc - gcc和内联的奇怪行为

c++ - 不明确的符号错误?

c++ - unsigned int 和 double 转换顺序

c - 在 c 中比较不相等的 char 数组的正确方法

c - 请解释一下这个比较字符串的方法

javascript - 为什么我的数组中的项目不显示在单独的行中?

android - 无法在 android opencv 2.3 中导入 ml.h