Re: pointer as argument and parameter



Eric Sosman wrote:

.... snip ...

If you tell the compiler that `b' is an array of `char*',
the same sort of thing goes on, except that the choice of
which rules to apply is a little different. Most of the
time, when you mention the name of an array you get a pointer
to the array's initial element -- hence the equivalence of
`b' and `&b[0]' in the function call. Since `b' is an
array of `char*', `b[0]' is one of those `char*' elements,
and `&b[0]' is therefore a `char**'.

I disagree. b[0] _is_ a char. It happens to be of the same type
as what is pointed at by a char* pointer. However *b is not a
pointer to a char. Thus "&b[0]" is not a char**.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: Need help to port VAX code to Alpha and to Itaninum
    ... Not really, the original code was wrong, and the compiler was not ... pointer to the start of the array. ... So you are trying to pass a pointer to a pointer to an array where you ... Also start looking at where you can add the "const" modifier to function ...
    (comp.os.vms)
  • Re: fast stable sort
    ... to a discussion of stable in-place merge sort. ... a unique pointer. ... Please describe how you are going to store that array of strings. ... Or b) you input strings to malloced (or ...
    (comp.programming)
  • Re: decrement past beginning is valid?
    ... > What I meant by legal is that a compiler will compile it. ... > that an array is the same as a pointer. ... behave the same way on all platforms. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: gdb not catching out-of-bounds pointer
    ... is also not defined by the C-standard, IOW: writing code in anything ... provided the library writer knows what the compiler writer guarantees ... etc.) that don't point into the same array than I would about the sort ... of pointer aliasing issue that started this sub-thread. ...
    (comp.unix.programmer)
  • Re: lockless file descriptor lookup
    ... It isn't clear whether you want to refresh the fd_ofiles pointer to the ... the array, or the fd'th element. ... This is actually intended to catch cases where the descriptor array has expanded and the pointer to fd_ofiles has changed, or the file has been closed and the pointer at the fd'th element has changed. ... I'm attempting to force the compiler to reload the fd_ofiles array pointer from the fdp structure. ...
    (freebsd-arch)