With GCC family of C compilers, we can mark some functions to execute before and after main(). So some startup code can be executed before main() starts, and some cleanup code can be executed after main() ends. For example, in the following program, myStartupFun() is called before main() and myCleanupFun() is called after main().
startup code before main() hello cleanup code after main()
Like the above feature, GCC has added many other interesting features to standard C language. See this for more details.
Related Article :
Executing main() in C – behind the scene
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Executing main() in C/C++ - behind the scene
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Functions in C/C++
- How to print "GeeksforGeeks" with empty main() in C, C++ and Java?
- What happens when a function is called before its declaration in C?
- Importance of function prototype in C
- Const Qualifier in C
- return statement vs exit() in main()
- How to Count Variable Numbers of Arguments in C?
- exit(), abort() and assert()
- What is evaluation order of function parameters in C?
- Static functions in C
- What is the purpose of a function prototype?
- How can I return multiple values from a function?
- Does C support function overloading?