|
|
Defining variable between function argument list and {}
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: Passing va_list by reference to a function - comp.lang.c ...... cleaner way to portably pass a va_list to a function by reference? Also, what is ... always the same argument of the variable argument list. The xprintf() function ... Difference between passing a number and a variable to a subroutine ...... at what is different between ... argument is a > variable or a ... between passing a number and a variable to a subroutine ... Passing va_list by reference to a function ... read base workspace from function workspace - comp.soft-sys.matlab ...... and returns the results in the specified output variables. Using the evalin output argument list ... When executed it outputs all of the variables in a function to the ... Define a variable at a fixed address? - comp.compilers.lcc ...Passing va_list by reference to a function - comp.lang.c ..... have ... of which I pass the address ... as argument or when assigning to a variable of that type. What is the ... Unknown number of return values - comp.soft-sys.matlabHowever, defining fun_handle=@(x)fun(x) (defining the function handle using an argument list), nargout(fun ... the number of output arguments to depend on the input variable ... Using GRPSTATS to compute statistics on multiple variables by ...... that issue by writing my own correlation function ... reason will only call Fun1 with a matrix argument if ... variables, use COMPUTE ... vary greatly > > between the variables ... BASIC problem calling LIB$ RTL - comp.os.vmsNAME FROM$ AS TO$ Also declaring all variables and ... I prefer seeing what is really being executed ... way (that I know of) in BASIC to declare a function argument ... How to pass enum as default argument - comp.lang.c++.moderated ...Difference between passing a number and a variable to a subroutine ..... property list identifier INTEGER(HID_T ... demonstrates how you can use enum as function argument ... Catching un-initialised stem variables - comp.lang.rexx... ll need to set it when you define ... have used your old single-argument function by ... variable that contains a list of variables to expose, an intermediate function ... Using C and Assembly code: 64Bit Calling convention - comp.lang ...... HLL does and maps to the processor (or, what is ... rSP isn't properly up- >> dated between function calls ... argument functions, the fixed part of a variable argument list ... Variadic function - Wikipedia, the free encyclopediaIn computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions ... Functions with Variable Argument Lists (C++)... variable lists are declared using the ellipsis (...) in the argument list, as described in Variable ... C++ Function Definitions 7/13/2012 1:04:55 AM
|
|
|
|
|
|
|
|
|