Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C, what does it mean when a variable is declared in between a function header and body? [duplicate]

Tags:

c

syntax

A few times now, I've encountered code like this:

int
main(argc, argv)
int argc; char **argv;
{
    ...
}

Why are argc and argv declared in this way?

like image 414
Matthew Avatar asked Apr 27 '12 17:04

Matthew


1 Answers

This was the syntax that was used for K&R* style parameter lists.

* K&R - Brian Kernighan and Dennis Ritchie, authors of the book, "The C Programming Language."
Dennis Ritchie was also the creator of the C programming language and with Ken Thompson, the UNIX operating system.

like image 87
Michael Goldshteyn Avatar answered Nov 15 '22 06:11

Michael Goldshteyn