Bey-Hey 2022-03-09 13:43 采纳率: 82.6%
浏览 33
已结题

形参和实参数量一样,但是显示错误参数太少无法正常工作

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
运行结果及报错内容 too few arguments to function
我的解答思路和尝试过的方法
我想要达到的结果
 #include<stdio.h>
 int temp;
int  swap1(int *a,int*b)
 {
     temp=*a;
     *a=*b;
     *b=temp;
     printf("%d%d",a,b);
 }
 int main(int x,int y)
 {
     printf("Please input two numbers:");
     scanf("%d%d",&x,&y);
     swap1();
     printf("%d%d",x,y);
 }


  • 写回答

1条回答 默认 最新

  • 谛凌 2022-03-09 13:50
    关注

    你14行调用swap1函数的时候没有传参数啊
    参考

     #include<stdio.h>
     int temp;
    int  swap1(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);
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 3月17日
  • 已采纳回答 3月9日
  • 创建了问题 3月9日