home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!microsoft!wingnut!pauljo
- From: pauljo@microsoft.com (Paul Johns)
- Subject: Re: Passing 2-d arrys to functions
- Message-ID: <1993Jan11.234545.22712@microsoft.com>
- Date: 11 Jan 93 23:45:45 GMT
- Organization: Microsoft Corp., Redmond, Washington, USA
- References: <RUNE.93Jan10125255@pandora.nta.no> <C0Hw4n.Hy9@knot.ccs.queensu.ca> <C0H9sA.BGw@newsserver.technet.sg><24568@alice.att.com> <726521188snx@trmphrst.demon.co.uk>
- Distribution: usa
- Lines: 26
-
- In article <RUNE.93Jan10125255@pandora.nta.no> rune@nta.no wrote:
-
- > I'm including a little program that seems to work fine. Here I'm pas-
- > sing only the pointer to a two dimensional array. Can I expect such
- > programs to work, and if so, why?
-
- Your program will work. It is set up correctly.
-
- But you are NOT passing the pointer to a two-dimensional array.
-
- You are passing the pointer to an array of pointers. Although
- the syntax for accessing an element is the same (x[i][j]), the
- underlying data structure is entirely different.
-
- Note, for instance, that there's no reason that the row lengths
- need to be the same.
-
- When you pass a two-diminsional array, you really pass a pointer
- to a one-dimensional array (i.e. TYPE (*p)[ROW_SIZE]; )
-
- Your example passes a pointer to a pointer.
-
- Check the assembly language generated by the compiler to see the
- difference.
-
- // Paul
-