×
Namespaces

Variants
Actions
Revision as of 13:35, 10 January 2010 by hugovk (Talk | contribs)

String comparison

From Nokia Developer Wiki
Jump to: navigation, search
TBuf<50>	Buffer;
 
Buffer.Copy(_L("somestring"));
 
/*
* Compare the first letter
*
* TPtrC Left(TInt aLength)
*
*/

if (!(Buffer.Left(1).Compare(_L("A"))))
{
// Do something
}
 
 
/*
* Compare the last letter
*
* TPtrC Right(TInt aLength)
*
*/

if (!(Buffer.Right(1).Compare(_L("o"))))
{
// Do something
}
 
 
/*
* Compare a middle letter to the end
*
* TPtrC Mid(TInt aPos)
*
*/

if (!(Buffer.Mid(5).Compare(_L("xyz"))))
{
// Do something
}
 
 
/*
* Compare N letters
*
* TPtrC Mid(TInt aPos, TInt aLength)
*
*/

if (!(Buffer.Mid(2, 3).Compare(_L("xp"))))
{
// Do something
}
40 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×