Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Defining variable between function argument list and {}

0 views
Skip to first unread message

Kuhl

unread,
Nov 6, 2009, 9:36:45 AM11/6/09
to
Variables of a C function is usually defined inside the {} of the
function. But I also see some variables being defined between the
function argument list and {}, such like below.

int unzip(in, out)
int in, out; /* input and output file descriptors */
{
...
}

What's the purpose of defining the variables here? Thanks.

mukesh

unread,
Nov 6, 2009, 9:42:37 AM11/6/09
to

it is old C style

Jens Thoms Toerring

unread,
Nov 6, 2009, 9:57:39 AM11/6/09
to

It's the way things were done before the first C standard
came out about 20 years ago. Instead of

int unzip( int in, int out )
{

you had to write

int unzip(in, out)
int in, out;

{

since back then you couldn't set the types of the arguments
in the argument list itself.

If you find that in some programs it's either because the
program is very old or, for some reasons, the author wants
to make sure it would even compile on ancient C compilers,
predating the first C stamdard.

Regards, Jens
--
\ Jens Thoms Toerring ___ j...@toerring.de
\__________________________ http://toerring.de

0 new messages