Re: Array pointers

From: Erik Max Francis (max_at_alcyone.com)
Date: 08/16/04


Date: Mon, 16 Aug 2004 09:57:22 -0700

Jens.Toerring@physik.fu-berlin.de wrote:

> A two-dimensional array like your
>
> int array[2][3];
>
> doesn't decay to a pointer to pointer to int but just a pointer to
> int.

No, it decays to an int *[3].

> > and then when I run the binary, I get a segmentation fault.
>
> Yes, that was to be expected...

Your proposal would also fail.

-- 
 __ Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Divorces are made in Heaven.
    -- Oscar Wilde


Relevant Pages

  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
    (comp.lang.c)
  • Re: C# - getting binary data from .lib
    ... Use Marshal.AllocHGlobal to allocate the memory and pass this IntPtr to the ... int retCode = create(id, scale, ptrImage); ... You now control the pointer returned. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Another spinoza challenge
    ... You should test against the int type's limits: ... typedef struct complex ... a pointer to an integer ... A macro is preferable because it is replaced by inline code, ...
    (comp.lang.c)
  • Re: C# - getting binary data from .lib
    ... int create(int id, int scale, unsigned char *image); ... unsigned char* ptrImage = NULL; ... // Read through entire pointer byte by byte and put into managed array ...
    (microsoft.public.dotnet.framework.interop)
  • Re: C# - getting binary data from .lib
    ... then there is a problem with the ptrImage ... int retCode = create(id, scale, ptrImage); ... You now control the pointer returned. ...
    (microsoft.public.dotnet.framework.interop)