About 836,000 results
Open links in new tab
  1. Executing main() in C/C++ - behind the scene - GeeksforGeeks

    Sep 13, 2023 · Let us first understand what happens under the hood while executing a C program in Linux system, how main () is called and how to execute a program without main (). Following setup is considered for the demonstration. From C/C++ programming perspective, the program entry point is main () function.

  2. What should main () return in C and C++? - Stack Overflow

    Oct 15, 2008 · What is the correct (most efficient) way to define the main() function in C and C++ — int main() or void main() — and why? And how about the arguments? If int main() then return 1 or return 0?

  3. main Function in C - GeeksforGeeks

    Mar 7, 2025 · The main function is the entry point of a C program. It is a user-defined function where the execution of a program starts. Every C program must contain, and its return value typically indicates the success or failure of the program. In this article, we will learn more about the main function in C. Example:

  4. Main function - cppreference.com

    Jun 6, 2024 · The main function is called at program startup after initialization of the non-local objects with static storage duration. It is the designated entry point to a program that is executed in hosted environment (that is, with an operating system).

  5. main function and program execution | Microsoft Learn

    Sep 28, 2022 · Every C program has a primary function that must be named main. The main function serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program.

  6. c - How does int main() and void main() work? - Stack Overflow

    Sep 21, 2016 · Most C developers tend to use int main() on all of its variants, though void main() will also compile. Find the answer to your question by asking.

  7. What does main() return in C and C++? - GeeksforGeeks

    Sep 19, 2019 · What does main () return in C and C++? According to coding standards, a good return program must exit the main function with 0. Although we are using void main() in C, In which we have not suppose to write any kind of return statement but that doesn’t mean that C code doesn’t require 0 as exit code.

  8. Learn Programming: Entry Point (main()) and Program Structure

    Oct 29, 2021 · Languages such as C and Java use a function or method, called main(), on which the initial code must be implemented. Other languages can define different conventions to start a program. Similarly, libraries, frameworks or engines can establish their own conventions regarding how a program implemented using them should start.

  9. Void Main(), Main() and Int Main() in C/C++ - Know Program

    Void main (), main () and int main () | Main is a function with a special characteristic that program execution always start from main ().

  10. What should the main() return in C and C++? - Intellipaat

    Mar 11, 2025 · In both C and C++ programming, the main() function is the entry point of the program. The return type of the main() has to be an int type, as it checks whether the program ran successfully or failed. The return 0 indicates the program finished successfully, while the return 1 or any value other than zero signals failure or error.

Refresh