E:\C语言练习\collect2.exe [Error] ld returned 1 exit status

问题遇到的现象和发生背景

,求解决一下这个程序有什么问题?

问题相关代码,请勿粘贴截图

#include
void swap(int a,int b);

int main()
{
int a,b;
scanf("%d %d",&a,&b);
swap(a,b);
return 0;

void swap(int a,int b)

{
int t;
a=t;
a=b;
b=t;
printf("%d %d",a,b);
}
}

运行结果及报错内容

E:\C语言练习\collect2.exe [Error] ld returned 1 exit status

我的解答思路和尝试过的方法

E:\C语言练习\collect2.exe [Error] ld returned 1 exit status

你的意思想让A和b交换的思想吧,
格式有误
int t=a
a=b
b=t,
报错原因,你把未定义的t给了a,又给了b,系统不知道这是一个什么书

你贴出来的代码也不全,我也不懂哪报错,我按照你的想法修改了

img

img

#include <stdio.h>

void swap(int a,int b);

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    swap(a, b);
    return 0;
}
void swap(int a,int b)
{
        int t;
        t=a;
        a=b;
        b=t;
        printf("%d %d",a,b);
}