u/skeetoin r/C_Programming • Recommends
On “What Happens Before the Main Function is Called ?”
Conveniently just a week old: [Windows Internals Crash
Course]
The short: the operating system does some process initialization, then
calls the program entry point (`mainCTStartup` in your case) which is
usually defined by the C runtime (CRT). It does some CRT initialization to
set up for running a C program, which includes parsing the command line
string from the operating system, then finally calls `main` which is
defined by your program. When `main` returns, it does some teardown like
flushing streams, then either passes control back to the operating system
or uses an exit system call.
The CRT is optional, and you
can define `mainCRTStartup` yourself, though you don't get to use the C
s…