What is the difference between main in a C program and in a C++ program?
Other than
- return statement ( default 1 in C,`0 in C++)
-
syntax:
int main() { /* … */ } int main(int argc, char* argv[]) { /* … */ } int main() , void main() ,etc ...
Mainly:
-
difference between main in C Program & C++ program
-
Are there any differences between C++98, C++03 and C++0x according to the ISO standard? i.e program’s entry point (program startup implementation), etc.
In modern C, and modern C++:
mainis always eitherint main()orint main(int, char*[]).returnfrom main explicitly.return 0.[(I’ve checked the C99 standard now and edited this paragraph.)] For your second question, in C99 you must have precisely one of the two
mainfunctions. In C++ the standard says that a program is well-formed if it has amainfunction that returnsint, and that every conforming implementation must accept the two listed versions as an entry point (for a “hosted program”, e.g. not for the Linux kernel); see 3.6.1. [/edit] To the best of my knowledge, calling conventions are also not part of the standard.I don’t understand your question about memory, but do note that neither C99 nor C++03 have anything but a rudimentary memory model, whereas the new C++0x explicitly adds a memory model in order to enable well-defined concurrent and atomic operations.