you are just calculating log base 10, which is correct.

digits = 1+log10(x);
str = MemPtrNew(1+digits);      // add 1 for the null at the end


-----Original Message-----
From: Roberto Amorim [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 25, 2000 11:47 AM
To: Palm Developer Forum
Subject: Re: Correct memory allocation (long int -> character array)


Try this code:

j=1;
for (i=z; i > 0;i=i/10) j++; 
s = (char *)MemPtrNew(j);

[]s
Roberto Amorim

-- 
 =========================================
 |  ___                                  |
 | /   \ Campanha contra e-mail com HTML |
 | \   / FITA ASCII                      |
 |  \ /                                  |
 |   X   ASCII RIBBON                    |
 |  / \  Against HTML e-mail             |
 | /   \                                 |
 =========================================

-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to