控制台输出MFC CString类型

#include 
#include "afxwin.h"

using namespace std;

int main()
{
	CString s1("Abcdefg");
	cout << "CString s1.length=" << s1.GetLength() << endl;
	cout << "CString s1=" << s1 << endl;
	wcout << "CString s1=" << s1 << endl;

	printf("CString s1=%s\n", s1);
	cout << s1.GetString() << endl;
	wcout << s1.GetString() << endl;

	LPTSTR p1 = s1.GetBuffer(4);
	printf("%s\n", p1);

	return 0;
}

控制台输出MFC CString类型_第1张图片

wcout << s1.GetString() << endl;    这句才输出了;

cout << "CString s1=" << s1 << endl;    这输出了地址;

MFC CString的GetBuffer() 返回类型是 LPTSTR;

你可能感兴趣的:(VC++,mfc,c++,CString)