问题描述
- locale::facet::_S_create_c_locale name not valid.
-
#include
#include
#include
#include
#includeusing namespace std;
int main()
{
locale china("chs");//use china character
wcin.imbue(china);//use locale object
wcout.imbue(china);
map word_count;
wchar_t word;
wifstream ifile("遮天.txt",wifstream::in);
if(ifile.fail())
wcerr << "Fail to read the file." << endl;
while(ifile >> word)
{
auto ret=word_count.insert({word,1});
if(!ret.second)
++ret.first->second;
}
for(auto r:word_count)
wcout << r.first << " occurs "
<< r.second
<< ((r.second > 1) ? " times" :" time") <<endl;
wcout << "Hello world!" << endl;
return 0;
}
出错信息:
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
解决方案
http://blog.sina.com.cn/s/blog_612144f301010691.html
解决方案二:
source::http://cruisever.blog.163.com/blog/static/786117572010817112310741/
Starting DSM SA Shared Services: terminate called after throwing an
instance of 'std::runtime_error'
what(): l......
答案就在这里:locale::facet::_S_create_c_locale name not valid