How to use run a function with function pointer in C

1 Answer

0 votes
#include <stdio.h> 

typedef void(*func_ptr)(int);

func_ptr f_ptr;

void print(int n);
 
int main(void)
{
    int n = 100;

    f_ptr = print;

    (*f_ptr)(n);
       
    return 0;
}
 
void print(int n)
{
    printf("%d\n", n);
}
 
/*
 
run:
 
100

*/


answered Nov 5, 2014 by avibootz

Related questions

1 answer 143 views
1 answer 127 views
1 answer 142 views
2 answers 143 views
1 answer 153 views
153 views asked May 16, 2022 by avibootz
2 answers 198 views
1 answer 154 views
...