News for hackers. Stuff that matters.
Re:A Little Story About the `yes` Unix Command by dreta on Thursday October 12, 2017 @03:38AM (#15456303)
Can anybody explain to me what's this syntax? This is the first time i see anything like it, and i've been programming in C since i was a teenager.

    main(argc, argv)
    char **argv;
    {
    }
Re:A Little Story About the `yes` Unix Command by ecma on Thursday October 12, 2017 @03:43AM (#15456321)
That's a K&R (Kernighan and Ritchie) style function declaration. Compilers still support it but the version you'd be more familiar with (ANSI C style) has been standard since at least the late 80s IIRC. ANSI C was standardised in 1989 but that process had been in progress for something like 5 years beforehand.
Re:A Little Story About the `yes` Unix Command by colejohnson66 on Thursday October 12, 2017 @06:44AM (#15457000)
Does it have to do with how, in BCPL (one of C’s ancestors), everything was basically an integer? So everything is an integer unless told otherwise?
Re:A Little Story About the `yes` Unix Command by boomlinde on Thursday October 12, 2017 @07:44AM (#15457258)
Specifically, everything is an integer with the auto lifetime (gets discarded with the stack frame) unless otherwise specified.

I think most modern compilers will warn on encountering such short hand due to the common error of accidentally declaring integers when you meant to assign a value to a variable you forgot to declare.

Re:A Little Story About the `yes` Unix Command by boomlinde on Thursday October 12, 2017 @07:03AM (#15457081)
main and argc are declared as int (technically auto int) by default. argv is declared and given its type between the function head and the function block, which is perfectly legal but quite unusual these days

This syntax is probably nice if you use a line oriented editor like ed

Re:A Little Story About the `yes` Unix Command by dreta on Thursday October 12, 2017 @07:18AM (#15457148)
I was mostly talking about the odd re-declaration of argv. Everything else is quite clear.
Re:A Little Story About the `yes` Unix Command by FRex on Thursday October 12, 2017 @07:24AM (#15457170)
It's not that hard or unlikely to run into it in old C code. The game Nethack is still being developed and it's programmed this way too (anything I looked at in its code at least).