如何修改可以输出整个字符串啊,现在这样只是输出h
来源:百度知道 编辑:UC知道 时间:2024/06/28 21:03:09
// str.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "afx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CString str("hello");
const char *a =(char*)(LPCTSTR)str;
cout<<a;
return 0;
}
vs 2005
//
#include "stdafx.h"
#include "afx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CString str("hello");
const char *a =(char*)(LPCTSTR)str;
cout<<a;
return 0;
}
vs 2005
(1)
CString str("hello");
TCHAR *a =(TCHAR*)(LPCTSTR)str;
wcout<<a<<endl;
(2)
CString str("hello");
char *a=new char[str.GetLength()+1];
memset(a,0,str.GetLength()+1);
wcstombs(a, str, str.GetLength()+1);
cout<<a<<endl;
delete a;
(3)
CString str("hello");
char *a=new char[str.GetLength()+1];
memset(a,0,str.GetLength()+1);
WideCharToMultiByte(CP_ACP,0,str,-1,a,str.GetLength()+1,NULL,NULL);
cout<<a<<endl;
delete a;
.
.
.
.
.
gh