On 6/30/2013 3:58 PM, Bernd Oppolzer wrote:
As I pointed out earlier, C NEVER passes arguments by reference.
Well, if you pass, say &record then the address of record
is passed in the argument list, so record is passed by
reference. However, one could argue that '&record' is a
pointer and the pointer is being passed by value so that
the data is being passed by reference.
Angels and pin heads, eh?
There is only one (kind of) exception to this rule, that is:
the name of a vector is always the same as the address of its first element,
that is
if x is a vector, then x is the same as &x[0],
so if you pass x (a vector) to a function, the address of the vector is
passed to the function.
This is not true for structures, where the whole structure is passed by value,
that is, copied into the argument list.
But again: the equation (x the same as &x[0]) is not limited to function calls,
it is true everywhere.
HTH
kind regards
Bernd
Am 30.06.2013 20:11, schrieb Steve Comstock:
My whole point was to address the assertion from an
earlier point in this thread that C invariably passes
arguments by reference.
As usual, the simple answer is 'it depends' and, as Shmuel
points out, the devil is in the details.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN