convert integer to a string ???

Login to reply to this topic.
Wed, 2004-10-13 06:20
Joined: 2004-08-16
Forum posts: 98
How can I convert an integer with the data type TInt32 to a string?
And then I can use LIT(KSTRING,"the integer's string");
then I can use iEikonEnv->InfoMsg(KSTRING) to show the integer out.

Who can give me some help ?
Or the solution to solve my problem without using my method ?

Wed, 2004-10-13 06:25
Joined: 2003-09-29
Forum posts: 32
convert integer to a string ???
Hi,

Following might work for you:
Code:
// make sure this is long enough or use HBufC and calculate
// length at runtime
TBuf<64> buf;
buf.Zero();
TInt32 integerToPrint = 54;
_LIT(KIntegerFormat, "Integer: %d");
buf.AppendFormat(KIntegerFormat, integerToPrint);

// buf now contains "Integer: 54"
// do whatever you like with it

Jari

Wed, 2004-10-13 07:44
Joined: 2004-10-12
Forum posts: 21
convert integer to a string ???
Jari's method will work great.

If this is for debugging and you just want to get the number out this works too:

TInt number;
number=SomeFunction();
TBuf<20> num;
num.AppendNum(number);
  • Login to reply to this topic.