Search
 
SCRIPT & CODE EXAMPLE
 

CPP

What should main() return in C++?

The return value for main indicates how the program exited. Normal exit is 
represented by a 0 return value from main. Abnormal exit is signaled by a 
non-zero return, but there is no standard for how non-zero codes are 
interpreted. As noted by others, void main() is prohibited by the C++ 
standard and should not be used. The valid C++ main signatures are:

int main()

and

int main(int argc, char* argv[])

which is equivalent to

int main(int argc, char** argv)

It is also worth noting that in C++, int main() can be left without a
return-statement, at which point it defaults to returning 0. This is also 
true
with a C99 program. Whether return 0; should be omitted or not is open to 
debate. The range of valid C program main signatures is much greater.

Efficiency is not an issue with the main function. It can only be entered and left once (marking the program's start and termination) according to the C++ standard. For C, re-entering main() is allowed, but should be avoided.
Comment

what do I return in int main() function c++

int main() {
  return 1;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: PUBG_APIKEY=<your-api-key npm t 
Cpp :: c++ program to convert celsius to fahrenheit 
Cpp :: C++ Automatic Conversion from double to int 
Cpp :: how to save system function output into a variable in c++ 
Cpp :: start google 
Cpp :: vector literal in cpp 
Cpp :: c# unity rendering object 
Cpp :: passing array to the function c++ 
Cpp :: omp multiple reductions 
Cpp :: how to add values in empty array using python 
Cpp :: C++ meaning :: 
Cpp :: using of and || c++ 
Cpp :: ubuntu dotnet create blazorserver linux 
Cpp :: c++ merging algorithm 
Cpp :: libraries required for gaming in c++ 
Cpp :: crtdbg c++ 
Cpp :: accepting multiple values from a function in cpp 
Cpp :: Arduino C++ servomotor random moving 
Cpp :: std::hash 
Cpp :: C++ operation 
Cpp :: ue4 array copy c++ 
Cpp :: c pointer syntax 
Cpp :: asio broadcast permission 
Cpp :: compile c++ program 
Cpp :: c++ calorie calculator using a for loop 
Cpp :: C++ Point to Every Array Elements 
Cpp :: qt widget list set selected 
Cpp :: c++ how to print out 
Cpp :: c++ suare 
Cpp :: how to pass arrays by reference c++ 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =