vs2008下几个CString转换char*的问题
char *p_list = NULL;
char *p_ins = NULL;
char *p_temp =NULL;
char tlist[100];
CString s("This is a test");
//way1: CString to char*
p_list = (LPTSTR)(LPCTSTR)s;
//VS2008 compile error: 无法从“LPTSTR”转换为“char *”
//way2: CString to char*
p_temp= s.GetBuffer(0);
strcpy(p_list,p_temp);//CString->char*
s.ReleaseBuffer(-1);
//VS2008 compile error: 无法从“wchar_t *”转换为“char *”
//way2: CString to char*
p_temp= s.GetBuffer(s.GetLength());
strcpy(p_list,p_temp);//CString->char*
s.ReleaseBuffer();
//VS2008 compile error: 无法从“wchar_t *”转换为“char *”
//way3:
p_list = (char*)s;
//error:无法从“CString”转换为“char *”
//way4:
p_list= new char[s.GetLength()+1];
strcpy(p_list,(LPCSTR)s);
//error:无法从“CString”转换为“LPCSTR”
//CString to char[]
strcpy(tlist,(char *)(const char*)s);
//VS2008 compile error: 无法从“CString”转换为“const char *”
相关推荐
Unicode下CString与char*之间的转换(vs2008绝对实用)
在VS2008中,默认的字符集形式是Unicode,但在VC6.0等工程中,默认的字符集形式是多字节字符集(MBCS:Multi-Byte Character Set),这样导致在VC6.0中非常简单实用的各类字符操作和函数在VS2008环境下运行时会报各种各样的错误,这里总结了在VS2008环境中 Unicode字符集下CString和char *之间相互转换的几种方法,其实也就是Unicode字符集与MBCS字符集转换。
C++编程之CString、string与、char数组的转换
主要介绍了C++编程之CString、string与、char数组的转换的相关资料,希望通过本文能帮助到大家,让大家学习理解这部分内容,需要的朋友可以参考下
vs2008-Unicode字符集下CString与char_互转换
在VS2008中,默认的字符集形式是Unicode,但在VC6.0等工程中,默认的字符集形式是多字节字符集(MBCS:Multi-Byte Character Set),这样导致在VC6.0中非常简单实用的各类字符操作和函数在VS2008环境下运行时会报各种各样的错误,这里总结了在VS2008环境中 Unicode字符集下CString和char *之间相互转换的几种方法,其实也就是Unicode字符集与MBCS字符集转换。
VS2008上位机串口通信简单例程
超详细的利用VS2008一步一步打造上位机串口通信软件的简单例程,步骤详细,并配有图片解说,相关源代码,绝对是不可多得的串口入门级的教程,看完此篇文档,我相信你也能写出属于你自己的串口软件!
数据类型转换(VC++VC++)
可实现任何数据类型之间的转换 VC++ 帮助编程人员快速适应从vc++6.0到VS2008之间的转换


