How to call a function with function pointer in C

1 Answer

0 votes
#include <stdio.h>

float square(float x) {
    return x * x;
}

int main(void)
{
    float (*p)(float x);

    p = &square;

    printf("%f", p(5.7));

    return 0;
}



/*
run:

32.489998

*/

 



answered May 8, 2023 by avibootz

Related questions

1 answer 144 views
2 answers 244 views
1 answer 101 views
1 answer 157 views
157 views asked Apr 5, 2024 by avibootz
1 answer 161 views
1 answer 117 views
2 answers 287 views
287 views asked Aug 30, 2017 by avibootz
...