At 3:20 PM -0500 11/1/00, Matt Becker wrote:
>Can someone explain why this fails to work after the first iteration???
>CharPtr ptemp = "";
>CharPtr ptext = "";
You haven't allocated any space for the strings themselves. A CharPtr
is always 4 bytes long, and is generally the address of a block of
characters. In this case, you set them both o the address of a
zero-length string. Later, you try to write to the strings, and end
up writing all over memory in some semi-random location.
Here's one way to do it, there are lots of others:
// change this constant to be whatever your longest string might be
#define kMaxPossibleStringLength 50
// Set up the strings themselves: they are arrays of characters
Char tempStr[kMaxPossibleStringLength + 1];
Char textStr[kMaxPossibleStringLength + 1];
CharPtr ptemp = tempStr;
CharPtr ptext = textStr;
Now the rest of your code should work, I think. You don't even need
the variables ptemp and ptext, you could just use tempStr and textStr
in their place.
Hope this helps.
Dave Johnson
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/