views:

495

answers:

1

Hi

I simply wanna convert a TBuf to TInt in Symbian. I tried to do it the following way:

TBuf<2> buf;
buf.Copy( _L("10"));

TInt valInt;
TLex8 lex(buf);
lex.Val(valInt);

Here I get then the error message:

Error:  #289: no instance of constructor "TPtrC8::TPtrC8" matches the argument list
        argument types are: (TBuf<2>)

Help would be very much appreciated!

Thanks

+2  A: 

If you are using TLex8, you have to use TBuf8.

Try this (My Symbian C++ is rusty, but this should be close):

TBuf8<2> buf;
buf.Copy(_L8("10"));

TInt valInt;
TLex8 lex(buf);
lex.Val(valInt);
Alex B
.. or alternatively, use TLex (which is an alias for TLex16). BTW, `buf.Copy("10")` won't work, you need e.g. `_L8("10")` to make it a descriptor literal.
laalto
Indeed. Well spotted.
Alex B