Skip to main content
C++

main function in C++

By January 1, 2020January 5th, 2020No Comments
The main function runs automatically when a C++ program is compiled and executed. Let’s assume the program is written inside a file called main.cpp. “.cpp” is the file extension for all C++ files just like HTML files have a “.html” extension.
int main{
}
Compile:
g++ main.cpp
Execute:
./a.out

Leave a Reply