字符集与文件
#define _UNICODE
#include <tchar.h>
#include <fstream>
#include <iostream>
using namespace std;
int _tmain(int argc, TCHAR* argv[])
{
_tsetlocale(LC_ALL,_T("chs"));
TCHAR szTemp[] = _T("Hello 中国");
//打印字符串
#ifdef _UNICODE
wcout<<_T("字符串:")<<szTemp<<endl;
wcout<<_T("字符个数:")<<_tcslen(szTemp)<<endl;
wcout<<_T("字符串占用存储空间:")<<sizeof(szTemp)<<endl;
#else
cout<<_T("字符串:")<<szTemp<<endl;
cout<<_T("字符个数:")<<_tcslen(szTemp)<<endl;
cout<<_T("字符串占用存储空间:")<<sizeof(szTemp)<<endl;
#endif
//文件输出字符串
#ifdef _UNICODE
出错wfstream f(_T("D:\\test.txt"),ios::out);
#else
fstream f;
f.open(_T("D:\\test.txt"),ios::out);
f<<szTemp;
#endif
return 0;
}
高手告诉我一下wfstream 怎么用啊