Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is int main(int, char const* const*) well formed?

Tags:

c++

c++11

According to the C++11 standard, is the following program well-formed and portable C++?

int main(int argc, char const* const* argv) {}
like image 584
Anton Golov Avatar asked Jun 26 '12 21:06

Anton Golov


Video Answer


1 Answers

No. In a pure portable C++ program, the argv argument, if present, has no const modifiers.

Edit: See section 3.6.1.2 of the C++11 draft standard, which (in the version I have before me) states:

An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main:

int main(){ /*...*/ }

and

int main(int argc, char* argv[]) { /* ... */ }

like image 78
Jonathan Grynspan Avatar answered Sep 28 '22 09:09

Jonathan Grynspan