What happens if I cast a function pointer, changing the number of parameters

前端 未结 8 1676
孤街浪徒
孤街浪徒 2020-12-16 19:07

I\'m just beginning to wrap my head around function pointers in C. To understand how casting of function pointers works, I wrote the following program. It basically creates

8条回答
  •  时光取名叫无心
    2020-12-16 19:47

    If you take a car and cast it as a hammer the compiler will take you at your word that the car is a hammer but this does not turn the car into a hammer. The compiler may be successful in using the car to drive a nail but that is implementation dependent good fortune. It is still an unwise thing to do.

提交回复
热议问题