今天看到了vector,于是就想实现一下,打印字符之类的太简单了,在此就不提了,我的想法是把中文存在vector中,费了半天只能打印出问号???最后发现是我给的setlocale不对
#include <iostream>
#include<clocale>
#include<algorithm>
#include<functional>
#include<vector>
using namespace std;
void show(wchar_t a)
{
wcout<<a<<"\t";
}
int main()
{
vector<wchar_t>x;
setlocale(LC_ALL,"zh_CN.UTF-8");
const wchar_t *p = L"中";
for(int i=0;i<10;i++)
x.push_back(*p);
for_each(x.begin(),x.end(),show);
bool k=0;
if(k)
cout<<"kkkkk\n";
else
cout<<"sssssssssss\n";
return 0;
}
还是有问题,我不知到是我的编译器的问题还是程序的问题,复杂一点的字打印不出来