zoukankan      html  css  js  c++  java
  • linux 中文输出

    #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string>
      4 #include <fstream>
      5 #include <sstream>
      6 #include <iostream>
      7 #include <iomanip>
      8 
      9 int main()
     10 {
     11         std::basic_ifstream<wchar_t, std::char_traits<wchar_t> > fs("./test.txt");
     12         if ( fs.fail() )
     13         {
     14             printf("Cannot open , errno !
    ");
     15             return -1;
     16         }
     17         //std::locale lc("zh_CN.UTF-8");
     18         std::locale lc("");
     19         std::locale::global(lc);
     20         fs.imbue(lc);
     21         wchar_t line[256];
     22 
     23         while ( !fs.eof() )
     24         {
     25             line[0] = 0;
     26             fs.getline(line, sizeof(line));
     27             std::wcout<<"content: "<<line<<std::endl;
     28             printf("
    ---> %ls  ,%d  eof:%d 
    ", line,sizeof(wchar_t), fs.eof());
     29         }
     30 
     31         printf("press any key to continue.
    ");
     32         getchar();
     33 
     34         return 0;
     35 }
  • 相关阅读:
    Codeforces Round #534 (Div. 2) D. Game with modulo 交互题
    传球游戏 dp
    欧拉通路和欧拉回路
    HDU 1116
    HDU 4970
    HDU 4557
    HDU 4864
    HDU 1565
    HDU 3046
    HDU 4240
  • 原文地址:https://www.cnblogs.com/iclk/p/6873795.html
Copyright © 2011-2022 走看看