I'm going to ask everyone's indulgence on this topic just one more time.
Dan wrote:
s1 is still a pointer to a character string. The only distinction is that
when declared as an automatic, s1 points to someplace in the stack (as
opposed to someplace else in the dynamic heap)
Mitch asks: Where does the s1 pointer exist? I understand it points to an
address on the stack, but where in memory does the pointer itself live?
Thanks again...
Mitch (thank you for not putting me on your kill list)
Note: I do use the Pilot news groups but I find I like list servers better.
If Palm decides to create another list for questions like this, it would
definitly be a benefit to them and us.
> -----Original Message-----
> From: Dan Rowley [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, March 10, 1999 1:59 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Variable storage question
>
> > Thanks to everyone who offered answers to my question. It's starting to
> make
> > sense now. Hope you don't mind if I dig a little further.
> >
> > If I understand correctly, char s1[]= "Hello"; puts that array of
> characters
> > (plus the NULL) on the stack. Could I then execute something like
> > printf("%s", s1) and have it print Hello? If true, when that printf
> runs,
> > how does it know which bytes to pull off the stack. I might have added
> > additional things to the stack, so how does it know where to find it if
> > there is no pointer to it? If I could understand that, I'd really be
> getting
> > somewhere. Thanks.
> >
> Whether it's on the stack or someplace else is immaterial - s1 is
> still
> a pointer to a character string. The only distinction is that when
> declared
> as an automatic, s1 points to someplace in the stack (as opposed to
> someplace else in the dynamic heap) for the current function, and will be
> valid only so long as it's in scope. Your stack is just another block on
> the heap, so an address in the stack is just as valid as an address in
> another block - the only difference is that when the stack frame is popped
> off at the end of your function, references to s1 (say, if you'd passed
> the
> pointer to another function) would no longer be valid.
>
>
> --
> Dan Rowley
> Innovative Computer Solutions
> Developers of fine software for Newton, Windows CE, Palm Computing
> Platform,
> Windows, and MacOS