Regards,
Greg
Dietsche http://www.gregd.org/
GForce
Programming: http://calc.gregd.org
Detached
Solutions: http://www.detachedsolutions.com
----- Original Message -----From: JudeCN@aol.comSent: Wednesday, September 03, 2003 7:12 PMSubject: [A89] Re: c troubleI second lord_nightrose. If you haven't written anything, then why are you automatically saying that we are incorrect? I too have authored many programs (about as much as he), including Menu Lib, a compile-time lib for TIGCC that handles a great deal of string operations, including multi-dimensional string arrays. I think we know what we are talking about.
Jude Nelson
>>Mike McElroy (a.k.a lord_nightrose) wrote:
>>"Dynamic anything" can be dangerous because you might, if you're not >>careful, end up with your variables overwriting each other. Like I said.
>>>>**foo is as said a pointer to a pointer to a char. if something
>>>>else can overwrite this char (or any of the pointers) or any of the
>>>>chars in the contigious block that the declaration char foo[3][3]
>>>>allocates, has absolutley nothing to do with this.
>>Did you really read what I said? You just combined my two examples into one... >>char foo[3][3] and char **foo weren't supposed to be the same thing. I never said >>they were. I said that you can use char **foo as an array. You simply don't have >>the assurance that your data is intact as you would with char foo[3][3].
>>Looking at your TICalc author profile, I notice you said you program for ASM and >>have authored no programs. I, on the other hand, program for ASM, C, and BASIC, >>and have authored 60 programs. Perhaps you should take this into account before >>you say I "obviously know nothing about C and arrays and pointers." I especially >>urge you to look at the source code to my BASIC-accessible C library, MLib. >>Might change your mind.
>>Mike McElroy (lord_nightrose)
>>>>Olof Hedman <alh@home.se> wrote:
Mike McElroy wrote:
> 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.
And this is about as f*d up as the last post. What in the world are you
talking about?
You obviously know nothing about C and arrays and pointers.
char **foo is as said a pointer to a pointer to a char. if something
else can overwrite this char (or any of the pointers) or any of the
chars in the contigious block that the declaration char foo[3][3]
allocates, has absolutley nothing to do with this.
infact you can be just as sure or unsure.
its.. as scott said, hard to explain because your statement is so
fundamentally wrong.
Something else can change it if you happen to have another pointer
somewhere pointing to the same place.
And why would dynamic anything generally be a bad idea?
You should never allocate more memory then you use, specially not on a
low memory device as a calc.
Sometimes you use static buffers for speed gain or general lazyness but
thats about it.
--Olle