Re: passing char arrays by reference



Keith Thompson said:

Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:
[...]
To be precise, a pointer /is/ a reference.

In C, yes. There are other contexts in which "pointer" and
"reference" mean different things. (I'm thinking of C++.)

Right. I was referring to clc::reference, not c++->reference.


Note that this does not mean that passing a pointer equates to
pass by reference. It doesn't. You can pass a reference in C, but
you can't pass /by/ reference!

Agreed. But another way to look at it is that passing by
reference is an abstract concept that C doesn't support directly,
but you can *implement* pass-by-reference in C by careful use of
pointers.

How?

Similarly, C doesn't directly support linked lists, but
you can implement linked lists by careful use of pointers.

Linked lists, I'll grant you - but pass-by-reference in C? This I
have to see. :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: Real World Flunks (Re: Why is Object Oriented so successful)
    ... AndyW wrote: ... "modeling the real world". ... CADD screen closely matches the object pointers in a typical real- ... I think the fact one has a reference to it ...
    (comp.object)
  • Re: The Java no pointer big fat lie!
    ... > reference types, it wouldn't be a good comparison. ... and what you can't - and there is a big difference in Java to C and C++. ... You cannot change it in the language itself, ... Thus I would distinguish pointers from ...
    (comp.lang.java.programmer)
  • Re: Array comparison
    ... > Deep and recursive. ... the pointers and comparing their referents instead of comparing the ... >> arrays, then I think you also need to argue against assigning arrays. ... semantics (notably, reference counting). ...
    (alt.comp.lang.borland-delphi)
  • Re: Pointers vs References: A Question on Style
    ... >> One good style rule is to never return null, ... Prefer references to pointers unless you need pointers' special ... The edit fields link to the XML via MVC. ... > 'funk', you should pass by reference, and catch errors at compile ...
    (comp.lang.cpp)
  • Re: C# equivalent to a smart pointer???
    ... My understanding is that the use of pointers in C# is strongly ... data sharing functionality similar to that provided by smart pointers in ... innately through the reference type. ... Whether this final action on the object can be done while disposing the ...
    (microsoft.public.dotnet.languages.csharp)