6

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?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Matthew
  • 28,056
  • 26
  • 104
  • 170

1 Answers1

12

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.

Michael Goldshteyn
  • 71,784
  • 24
  • 131
  • 181
  • Is there any advantage to using the K&R style today? The link you posted recommends the ANSI style. – Matthew Apr 27 '12 at 17:31
  • 2
    Even if your compiler still supports it, please do not use this style for new code. I cannot stress that strongly enough. Also, I updated the link to point to Wikipedia, which is more informative on the style and its history. – Michael Goldshteyn Apr 27 '12 at 17:32
  • 2
    There is no advantage. This is the old pre-standard C style, and while it's still supported, it is considered outdated. – Variable Length Coder Apr 27 '12 at 17:40