[A89] Re: c trouble
[Prev][Next][Index][Thread]
[A89] Re: c trouble
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
Follow-Ups:
References: