Reading a document which is dated 1988, I found a main()
function starting in this way:
main(argc, argv)
char *argv[];
{
//some statements...
}
Surprisingly, I noticed there is no return type and even no data type for the arguments of the function - except for argv[]
that is declared once more on the second line of the code.
Taking these considerations into account, my questions are: is that a valid syntax? If yes, why C language syntax is a bit different, nowadays?
That's the original, pre-1989 "K&R" function syntax. The return type (and even the parameter types) defaulted to int, and the parentheses contained only the names of the parameters, with their fully-typed declarations (if necessary) appearing before the first {
.