WEB开发网
开发学院手机开发Symbian 开发 symbian 描述符 TBuf和const char*的转换 阅读

symbian 描述符 TBuf和const char*的转换

 2010-05-31 19:50:00 来源:WEB开发网   
核心提示:you may need to add extra checks (for instance, checking whether the char pointer is null or not).Converting descriptors to C-strings may be done this way:const
you may need to add extra checks (for instance, checking whether the char pointer is null or not).

Converting descriptors to C-strings may be done this way:

const char* descriptorToStringL(const TDesC& aDescriptor)

{

TInt length = aDescriptor.Length();

HBufC8* buffer = HBufC8::NewLC(length);

buffer->Des().Copy(aDescriptor);

char* str = new(ELeave) char[length + 1];

Mem::Copy(str, buffer->Ptr(), length);

str[length] = '';

CleanupStack::PopAndDestroy(buffer);

return str;

}

上一页  1 2 

Tags:symbian 描述 TBuf

编辑录入:coldstar [复制链接] [打 印]
赞助商链接