In C, how is the main() method initially called?

后端 未结 7 2058
甜味超标
甜味超标 2020-12-07 09:04

How does a C program get started?

相关标签:
7条回答
  • 2020-12-07 09:58

    The operating system calls a function included in the C runtime (CRT) and linked into your executable. Call this "CRT main."

    CRT main does a few things, the two most important of which, at least in C++, are to run through an array of global C++ classes and call their constructors, and to call your main() function and give its return value to the shell.

    The Visual C++ CRT main does a few more things, if memory serves. It configures the memory allocator, important if using the Debug CRT to help find memory leaks or bad accesses. It also calls main within a structured exception handler that catches bad memory access and other crashes and displays them.

    0 讨论(0)
提交回复
热议问题