--- Cygnus Saint wrote:
> 
> i have the following code.
> 

There is so much wrong with this code (hopefully it's mostly just
typos) that it is hard to say.

>       ...
>       UInt32 price;
>       UInt32 disc;
>       ...
>       -------------------------

Are we supposed to infer from the above that you have declared a struct
which contains 2 UInt32's and their names are iPrice and iDisc?  (That
isn't what you have here.)

>       ...
>       Char*    price,disc;
>       ...

Are we supposed to guess that you allocated memory to hold two strings,
but didn't bother to show that code?  Or, are we supposed to believe
that you redeclared price and disc as Char* (previously you declared
them to be UInt32's) and the compiler didn't complain?

>       StrIToA (price, (UInt32)record.iPrice);
>       StrIToA (disc, (UInt32)record.iDisc);
>       ...

Code like the above will work correctly if:
1. record.iPrice and record.iDisc can be type-cast to UInt32's.
2. the 2 UInt32's can be converted to Int32's without data corruption
(StrIToA expects Int32's, not UInt32's.)
3. price and disc are both Char *.
4. price and disc point to memory you allocated, enough to hold the
chars of each string, plus the null terminator.

> 
> i set a breakpoint just before StrIToA function is executed. 
> Then, i check the value of 'price'
> and 'disc'. i was surprised that the first statement assigns the
> value of 'price' and 'disc' with
> the converted value of record.iPrice. 

Do you mean that both price and disc get a new value at the same time? 
Do you have all code optimizations turned off when you are debugging? 

> 
> How can i convert and assign the value of record.iPrice to price, and
> record.iDisc to disc?
> 

Sample code:

Char price[maxStrIToALen];
Char disc[maxStrIToALen];
// ...
StrIToA(price, (Int32)record.iPrice);
StrIToA(disc, (Int32)record.iDisc);


__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

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

Reply via email to