- #246
FactChecker
Science Advisor
Homework Helper
Gold Member
2023 Award
- 8,956
- 4,355
Please don't ever ask this without telling us what the complete error statement, including the line number, if given.yungman said:I have issue building the solution. VS gives me error.
Because main often returns a completion code. 0 = normal satisfactory completion. Anything else indicates a different kind of termination.1) Why I have to declare int main()? What is int for?
This is the standard way that the main program can be passed information when it is called on the command line or in scripts. Like if you want to tell main the name of an input file and an output file. nNumberofArg tells main how many arguments were on the command line. All the arguments are stored in the array pszArgs. The first one is special (if it is not null). It gives the name of the executable that is running and contains main. (See https://en.cppreference.com/w/cpp/language/main_function )2) Why in the first book, it just declare int main(). But in this book it has parameter like int main(int nNumberofArg, char* pszArgs[])?