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 164 views
2 answers 263 views
1 answer 112 views
1 answer 166 views
166 views asked Apr 5, 2024 by avibootz
1 answer 170 views
1 answer 131 views
2 answers 302 views
302 views asked Aug 30, 2017 by avibootz
...