[EMAIL PROTECTED] wrote:

>Hmmm... my experience is that if I didn't put a '\0' at the end, StrCopy
>would cause a few "memory allocation" error messages to pop up.
Something else was going on then. In C, using double quotes to create a 
string constant
always null-terminates it for you, automatically. So

char str[4] = "abc";

is simply shorthand for 

char str[4] = { 'a', 'b', 'c', '\0' };

That's why you always need to allocate one more character in the array 
than there are between the quotes.

>> No, you don't have to call MemPtrNew.  Doing a StrCopy to a stack-based 
array 
>of
>> chars should be OK, as long as the source is smaller than the destination.
>OK, another slap on my hand for not keeping awake during CS501
>(Compilers and Operating Systems) lectures, I beg to ask this : "when is
>an array not stack-based?"
When you allocate it explicitly with new, malloc, MemPtrNew, 
MemHandleNew, etc.

Dave Johnson

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to