描述符的使用

来源:互联网 发布:rice university 知乎 编辑:程序博客网 时间:2024/04/29 17:08

void HelloWorldL()
 {
 const TInt KHelloWorldLength = 14;
 
 TBuf<KHelloWorldLength>  tbuf(KTextHelloWorld);
 
 TBufC<KHelloWorldLength> tbufc(KTextHelloWorld);
 
 HBufC* hbufc = KTextHelloWorld().AllocLC();
 
 RBuf rbuf;
 rbuf.CreateL(KTextHelloWorld,KHelloWorldLength);
 rbuf.CleanupClosePushL();
 
 TPtrC tptrc(tbufc);
 
 TPtr tptr = hbufc->Des();
 
 console->Printf(KTextHelloWorld);
 console->Printf(tbuf);
 console->Printf(tbufc);
 console->Printf(tptr);
 console->Printf(tptrc);
 console->Printf(*hbufc);
 console->Printf(rbuf);
 
 CleanupStack::PopAndDestroy(2);
 
 }
void Func1()
 {
 TBuf<20> bufHelloWorld(KTextHello);
 _LIT(KString1,"The original string is /"%s/"/n");
 console->Printf(KString1,&bufHelloWorld);
 bufHelloWorld.Append(KTextWorld);
 _LIT(KString2,"The modifed string is /"%s/"/n");
 console->Printf(KString2,&bufHelloWorld);
 bufHelloWorld.LowerCase();//转换为小写
 _LIT(KString3,"The lowercase of the string is /"%s/"/n");
 console->Printf(KString3,&bufHelloWorld);
 bufHelloWorld.UpperCase();//转换为大写
 _LIT(KString4,"The uppercase of the string is /"%s/"/n");
 console->Printf(KString4,&bufHelloWorld);
 
 }