On December 7, 2001 11:20 am, you wrote:
> Hey ,
> I am facing a problem , i want to find an ASCII character value of an
> integer in my program.How can i do that?
> Kindly reply ASAP.
>
> Best Regards
> Khuram Mir

If it's a UInt8, you can just use it as a character wherever you can use a 
character, just typecast it to stop the compiler from complaining.  I.e:

        Char string[32];
        UInt8 num = ' '; // Decimal 32, I believe.

        StrPrintF(string, "The number represents: '%c'", num);

In the above example, 'string' now should contain the text:

        The number represents: ' '

If you are trying to display, say, a UInt32 creator ID as a four-character 
string, you can use the following code:

        Char *FourCharInt ( UInt32 value, Char *buffer ) {
          Char *ptr;

          ptr = (Char *)&value;
          StrPrintF ( buffer, "%c%c%c%c\0", ptr[0], ptr[1], ptr[2], ptr[3] );

          return buffer;
        }

Just copy and paste the above code, rename it to TwoCharInt, and remove two of 
the ptr[] references to display the string value of a UInt16.

Hope this helps, and if not, at least it's more publicly available code,

-- 
Matthew Bevan, Margin Software
 - Re-inventing the wheel, every time.


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

Reply via email to