> From: LarryLu
>
> I'm so confused about memory and pointers. I have a structure that is
> comprised
> of 6 character strings. I"m populating these strings from several text
> fields
> I have in one of my forms. When I try a command like TimeToAscii I get
> the error
> saying I have just written to ROM blah blah blah. I didn't use any of
> the Memory
> commands like MemPtrNew for any of these strings since I'm just going to
> write
> them as a record into my database once I get all 6 strings. I have a
> feeling
> this is my problem. So my question is, when do I need to use MemPtrNew
> or
> any of the handle api's? I don't plan on keeping these strings around
> very long,
> so do I need to do this?
>
>From your description of the problem, I would guess you are passing a Char *
in to TimeToAscii, similar to this:
UInt8 hours = 8;
UInt8 minutes = 20;
Char * pString;
TimeToAscii(hours, minutes, tfColonAMPM, pString); // error!
You haven't allocated any space to store the resulting string of characters.
Char * pString is a pointer to Char. Declaring it doesn't allocate any
space to store the characters. You could do something like this:
UInt8 hours = 8;
UInt8 minutes = 20;
Char pString[timeStringLength];
TimeToAscii(hours, minutes, tfColonAMPM, pString);
You should read a book on C programming to get a better understanding of
pointers.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/