指向函数错误的指针

thr*_*rax 2 c pointers function

你好伙计们,我在这里有点新鲜,而且我也一直在练习函数指针,我已经想出了这段代码:

 #include <stdio.h>
#include <stdlib.h>
typedef int (*fptr)(int,int);
void swapp(int*,int*);
int sub(int ,int );
int add(int ,int );
int operation(fptr,int,int);
int main()
{
    int n=10,n1=25;
    printf("%d+%d=%d",n,n1,compute(add,n,n1));
    printf("\n%d-%d=%d",(n>n1)?n:n1,(n<n1)?n:n1,compute(sub,n,n1));


    return 0;
}
void swapp(int *a,int *b){
    int temp=*a;
    *a=*b;
    *b=temp;
}
int add(int a,int b){
    return a+b;
}
int sub(int a,int b){
    if(a<b)
    swapp(a,b);
    return a-b;
}
int compute(fptr operation ,int a,int b){

    return operation(a,b);
}
Run Code Online (Sandbox Code Playgroud)

编译时我得到"分段错误(核心欺骗)任何人都可以帮助我调试这个?而且我只是看不出代码有什么问题

BLU*_*IXY 6

需要原型

int compute(fptr operation ,int a,int b);
Run Code Online (Sandbox Code Playgroud)

swapp(a,b);
Run Code Online (Sandbox Code Playgroud)

swapp(&a,&b);
Run Code Online (Sandbox Code Playgroud)