非MFC项目使用CString及如何打印

//#include "stdafx.h" //不使用预编译头
#include <iostream>
#include <cstdlib>
#include <atlstr.h>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    CString str1;
    str1.Format(L"Who R U ? NO.%d", 999);
    
    cout<<str1<<endl;//以常规方式输出
    wcout<<str1<<endl;//直接输出CString
    wcout<<str1.GetBuffer()<<endl;//输出GetBuffer()后的字符串呢?

    system("pause");
    return 0;
}
运行结果:
00416E08
00416E08
Who R U ? NO.999
请按任意键继续. . .

原文地址:https://www.cnblogs.com/tupx/p/3430039.html