[A89] Re: c trouble


[Prev][Next][Index][Thread]

[A89] Re: c trouble



fuk you stop sending me emails asshole or i will kill you coz i know where u live

>>> lord_nightrose@yahoo.com 09/03/03 07:56 AM >>>
In addition: Although you can use "char **foo" exactly the same way as "char foo[3][3]" (meaning you can read and write values in foo), you can't be guaranteed what "char **foo" will contain when you try to access its contents, since something might overwrite it. Though it might be nice to use for dynamic arrays and whatnot, it tends to be a bad idea.

Mike McElroy <lord_nightrose@yahoo.com> wrote:The major difference is that assigning a multidimension array by using "char foo[x][y]" gives it a static, defined size, while using "char **foo " doesn't restrict the program from overwriting the array with other variables, since it hasn't reserved a specific size. For example, if you had "char foo[3][3]", you'd reserve 9 bytes for characters; however, "char **foo" would only reserve the first byte at the location given for foo.
 
Mike McElroy (lord_nightrose)

Sebastian Reichelt <SebastianR@gmx.de> wrote:
> Yes, it looks like an identifier conflict. But size isn't an issue, as
> char foo[][] is the same as char *foo[]

Yes, mostly. It's not the same, but the compiler will happily take the
address of an array and treat it as a pointer to a single item, and vice
versa.

> or char **foo; it's a pointer to an array of pointers to characters.

No. A two-dimensional array is a single block of memory.

> If the size of a pointer isn't known, delete your compiler.

LOL!

-- 
Sebastian Reichelt


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software



Follow-Ups: