Is it possible to swap C functions?

后端 未结 5 538
难免孤独
难免孤独 2021-01-06 08:09

Looking to see if anyone knows if its possible to swap C functions...?

 void swap2(int(*a)(int), int(*b)(int)) {
   int(*temp)(int) = a;
   *a = *b;
   *b =          


        
5条回答
  •  时光取名叫无心
    2021-01-06 08:45

    Yes,you can. Think that a function-pointer is just a memory-address,the single requeriment is: where you will keep such address needs to be mutable. Say,int (*foo)() not really to where foo points to. May be to printf() or fopen().

提交回复
热议问题