in c++ main function is the entry point to program how i can change it to an other function?

前端 未结 13 1891
忘了有多久
忘了有多久 2020-12-03 01:12

I was asked an interview question to change the entry point of a C or C++ program from main() to any other function. How is it possible?

13条回答
  •  半阙折子戏
    2020-12-03 01:35

    It's very simple:

    As you should know when you use constants in c, the compiler execute a kind of 'macro' changing the name of the constant for the respective value.

    just include a #define argument in the beginning of your code with the name of start-up function followed by the name main:

    Example:

    #define my_start-up_function (main)
    

提交回复
热议问题