"&"符号显示错误,要求去掉

运行时显示要去掉"&"符号
问题相关代码
#include<stdio.h>
 int temp;
 //指针型形参
int  swap1(int *a,int*b)
 {
     temp=*a;
     *a=*b;
     *b=temp;
     printf("%d,%d\n",*a,*b);
 }
 //引用型形参
int swap2( int&a,int&b)//书上的标注是:形参前的"&"符号不是指针运算符,而是引用
 {
     temp=a;
     a=b;
     b=temp;
     printf("%d,%d\n",&a,&b);
 }
 int main()
 {
     int x,y;   //变量在这定义
     printf("Please input two numbers:");
     scanf("%d%d",&x,&y);
     swap1(&x,&y);    //此处需要传参
     printf("%d,%d\n",x,y);
     swap2(&x,&y);
     printf("%d,%d\n",x,y);
 }


报错内容:|12|error: expected ';', ',' or ')' before '&' token|

你这个是把c++的引用搞混了,c++&可以表示引用,而c里是表示的取地址,引用的传参不需要传地址,直接swap(a,b)就可以


int swap2(int &a,int &b)
 {
     temp=a;
     a=b;
     b=temp;
     printf("%d,%d\n",a,b);
 }

swap2(x,y);