Defining variable between function argument list and {}

  • Follow


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.
0
Reply chen_zhitao (70) 11/6/2009 2:36:45 PM

On Nov 6, 7:36=A0pm, Kuhl <chen_zhi...@yahoo.com> wrote:
> 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)
> =A0 =A0 int in, out; =A0 /* input and output file descriptors */
> {
> =A0...
>
> }
>
> What's the purpose of defining the variables here? Thanks.

it is old C style
0
Reply mukeshmca2 (19) 11/6/2009 2:42:37 PM


Kuhl <chen_zhitao@yahoo.com> wrote:
> 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.

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  ___      jt@toerring.de
   \__________________________      http://toerring.de
0
Reply jt68 (1134) 11/6/2009 2:57:39 PM

2 Replies
53 Views

(page loaded in 0.08 seconds)

Similiar Articles:













7/13/2012 1:04:55 AM


Reply: