An array is implemented as a pointer, the name of the array is a
pointer, so it's the same thing.

On 12/1/05, Michael Barton <[EMAIL PROTECTED]> wrote:
> No, that would be the equivalent of
>   char *token[]  // array of pointers
> not
>   char token[][]  // array of arrays.
>
> You have to know the size of every dimension in the array except the
> last one to do anything with it.  Usually that's all done by the
> compiler.  If you know the size of the array at run time, it's
> possible to fudge it by doing the array indexing math yourself, but
> you'd have to stretch quite a bit to come up with an example where
> it's useful:
>
> void blah(char *token, int width)
> {
>   printf("token: %c\n", token[width * 2 + 1]);
>   // token[2][1] -- that's the math the compiler would normally do
> }
>
> int main()
> {
>   char token[4][3];
>   token[2][1] = 'c';
>   blah((char *)token, 3); // send it the width of the array
>   return 0;
> }
>
>
> On 12/1/05, Yorch <[EMAIL PROTECTED]> wrote:
> > You can define it this way:
> >
> > void blah(char **token);
> >
> > this way you won't need to use the size and you can use that pointer
> > like a 2D array.
> >
> > On 11/30/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > Gah, I am not surprised I figured out the problem 5 minutes I send it to 
> > > the
> > > list.
> > >
> > > Though, to create some discussion on the list, I will ask this:
> > >
> > > Why cannot we define like so:
> > > void blah(char token[][])
> > > but:
> > > void blah(char token[][size])?
> > >
> > > Enlighten me! :D
> > >
> > >
> > >
> > > Quoting [EMAIL PROTECTED]:
> > >
> > > >
> > > >
> > > > So, I am trying to pass a 2D char variable to a function and then do 
> > > > some
> > > > stuff
> > > > with it. However, I am receiving this error and I am not quite sure why:
> > > >
> > > > "arithmetic on pointer to an incomplete type"
> > > >
> > > > Poking around the internet hasn't lead me to anywhere interesting. I 
> > > > thought
> > > > it
> > > > was just my compiler on the linux box so I wrote a test program in 
> > > > dev-c++ so
> > > > we can see if that was so. This is written and is compiled in C:
> > > >
> > > > void blah(char token[][]);
> > > >
> > > > int main()
> > > > {
> > > >         char token[1][1];
> > > >
> > > >         token[0][0] = 'c';
> > > >
> > > >         blah(token);
> > > >
> > > >         return 0;
> > > > }
> > > >
> > > > void blah(char token[][])
> > > > {
> > > >                     printf("token: %c\n", token[0][0]);
> > > > }
> > > >
> > > > It generates the same error.
> > > >
> > > > I am assuming, as usual, that it is something obvious and after spending
> > > > hours
> > > > (a good 4 hours straight) smashing my keyboard my eyes have gone out of
> > > > control!
> > > >
> > > > Thank you!
> > > >
> > > >
> > > > ----------------------------------------------------------------
> > > > This message was sent using IMP, the Internet Messaging Program.
> > > >
> > >
> > >
> > >
> > >
> > > ----------------------------------------------------------------
> > > This message was sent using IMP, the Internet Messaging Program.
> > > --
> > > ROM mailing list
> > > ROM@rom.org
> > > Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
> > >
> > --
> > ROM mailing list
> > ROM@rom.org
> > Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
> >
> --
> ROM mailing list
> ROM@rom.org
> Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
--
ROM mailing list
ROM@rom.org
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom

Reply via email to