The first example uses a function inherited from the legacy C dialect that preceded the first ANSI (1989) and ISO (1990) standards: namely, that you can write a function that does not indicate its return type, in which case the default type equal to int.
C void . ( ", , " ), . - , . (, , return; ), , :
parse_input()
{
if (condition())
return;
}
int main()
{
parse_input();
return 0;
}
, main :
main()
{
}
( : int, .)
, , . . script, !
. ++ void, C. void ++ , ( , return; ). -, main , -, --++ void :
void main()
{
}
, , main(), int main(), , ( , ). , , , !
, ++ ++, main - int. -: "" main, , return 0;. , C99 , , ++ 98 (, , ):
int main()
{
}
( , C, 1980 ). void return main ( , , , ).
, C C99, main() { } C ++. , ++ : , .
, () (void). , ++ void. , ++ void, (void). ++ . ++ () C, . ++ int func(); , C, int func(); ββ: , . C void, : (void) , () - .
, : ++ (void) , ++ - . , , . (void) unambiguosly " ", C, ++. ++, , , ++, C, : , ! , class Foo { public: Foo(void); virtual ~Foo(void) /*...*/ };
, int main() { ... }, , , , , . , . C , ββ !
main, , , . ( ++, main , C ). , int main() int main(void), , C ++. , main, ( , ).
, :
int main()
{
}
, ++ C, C : ANI-C , . main, , . , GCC -Wstrict-prototypes:
test.c:1:5: warning: function declaration isnβt a prototype [-Wstrict-prototypes]
-Wstrict-prototypes - C, ( -Wmissing-prototypes), , :
int main(void)
{
}
.
, main , int main(int argc, char **argv), .
++ , , main().
int main(int, char **)
{
}
, argc, ++ :
#include <cstdio>
int main(int, char **argv)
{
while (*argv)
std::puts(*argv++);
}