本文介绍了将数据从wchar *复制到cstring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将wchar *中的内容安全地复制到cstring.

wchar * buff =(wchar *)malloc(500);

cstring cbuff;

I want to know how to copy content from wchar * to cstring safely.

wchar *buff=(wchar*)malloc(500);

cstring cbuff;

How do I copy contents of buff into cbuff so that I can destroy buff?

推荐答案

cstring cbuff;

if(buff && (buff[0] != 0 ))
{
  cbuff = cstring(buff);
}



问候
Espen Harlinn



Regards
Espen Harlinn


cbuff = (LPCWSTR)buff;


WCHAR *buff=(WCHAR*)HeapAlloc(GetProcessHeap(),0,100);
//	 WCHAR *buff=(WCHAR*)malloc(100);
 wcscpy(buff,L"rajesh");
 CString cbuff;
 cbuff=CString(buff);
  // free(buff);
   HeapDestroy(buff);


这篇关于将数据从wchar *复制到cstring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 01:42