In Palm Speak you would:

VoidHand h = MemHandleNew(lengthofString);
CharPtr waterString = MemHandleLock(h);
// Now you can fill waterString with a string value

StrCopy(waterString,StringWithInteger);

// Then do your string conversion


In regular c this amounts to:

char * x = (char *)malloc(lengthofString);

which if lengthofString is always 20 would be equivalent to:

char x[20];


The difference is important on the Palm though.  Depending on what you want
to do with the handle later on, you may want to have it scoop up memory in
the Database portion, in which case you would use one of the Dm calls to
allocate space for the handle.  MemHandleNew does it on the heap. (I think).
It looks like from your sample though that you will just need to have it on
the heap, but it's hard to know the whole context.

Paul

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Dave
Carrigan
Sent: Tuesday, April 23, 2002 10:41 AM
To: Palm Developer Forum
Subject: Re: converting int to string


Jay Francis <[EMAIL PROTECTED]> writes:

>  Err err = 0;
>  Char * waterString;

You're only declaring a pointer to the string; you aren't allocating
storage to actually hold the characters.

You should get a good C book and read the chapter(s) on arrays and
string handling, specifically the difference between

  char *x;
  char x[20];

--
Dave Carrigan ([EMAIL PROTECTED])            | Yow! I've got to get these
SNACK
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | CAKES to NEWARK by DAWN!!
Seattle, WA, USA                            |
http://www.rudedog.org/                     |

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


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

Reply via email to