in c++ main function is the entry point to program how i can change it to an other function?
- 阅读更多 关于 in c++ main function is the entry point to program how i can change it to an other function?
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? In standard C (and, I believe, C++ as well), you can't, at least not for a hosted environment (but see below). The standard specifies that the starting point for the C code is main . The standard (c99) doesn't leave much scope for argument: 5.1.2.2.1 Program startup: (1) The function called at program startup is named main. That's it. It then waffles on a bit about parameters and return values but there's really no leeway there for changing the name. That's