views:

340

answers:

3

Hi

I have a TBuf variable in my code that looks as follows:

TBuf<100> test;
test.Copy( _L("02somestringofrandomlength"));

What I would like to do now, is to ignore the number (which takes the first two characters). Is there a nice way to extract the variable-length string from the test variable and thereby dismissing the number at the beginning?

many thanks

+1  A: 

Use TDes::Right(), i.e. TPtrC right = test.Right( test.Length() - 2 );

+4  A: 

Assuming it's always exactly the first 2 characters and the input length is greater than 2:

TPtrC tail = test.Mid(2);
laalto
Works fine. thanks very much
A: 

Why first copy the string and then chop it, if you can copy just the part you need?

test.Copy( _L("02somestringofrandomlength") + 2 );
xtofl
When downvoting, please tell me why. This code works, and does what was asked for.
xtofl