沉思の自习室

精神的最高境界是自由!

本站所有资料仅供学习使用!请勿复制、转贴和传播!!! 资料已使用 xiesir'student 密码加密!

 

解决Code::blocks中文乱码的问题,并支持C++11特性

 

一、设置编辑环境可以使用中文:
Settings -> Editor... -> Encoding settings
Use encoding when opening files 设置为 UTF-8

Code01

 

二、编译为中文程序:
Settings -> Compiler... -> Other compiler options
大陆用户在框内加上 -fexec-charset=GBK ,台湾用户加 -fexec-charset=BIG-5 。(Windows 10 直接支持命令提示符下显示 UTF-8字符,所以这个可以不必设置)

Code02 


或者

将 Settings -> Editor... -> Encoding settings -> Use encoding when opening files 设置为 WINDOWS-936。

在:
Settings -> Compiler... -> Other compiler options
框内加上:

-finput-charset=WINDOWS-936
-fexec-charset=GBK

即可。

 

三、支持C++11特性

在:
Settings -> Compiler... 下,勾选“Have g++ follow the C++11 ISO C++ language standard”
即可。

Cpp11

 

测试代码: 

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

// 一维数组 输出 Pascal三角形
int main()
{
    const int N = 8;
    string title = "\tPascal 三角形";

    for (auto &c : title)
        c = toupper(c);
    cout << title << endl << endl;

    int i, j, n[N + 1];
    cout << setw(5) << (n[1] = 1) << endl;

    for (i = 2; i != N; ++i)
    {
        cout << setw(5) << (n[i] = 1);
        for (j = i - 1; j != 1; --j)
            cout << setw(5) << (n[j] += n[j - 1]);
        cout << setw(5) << n[1] << endl;
    }

    cin.get();
    return 0;
}

 

 

 

四、CodeBlocks16.01 中 wxWidgets 3.0.2 的安装:

http://www.blogs8.cn/posts/WMSTLel
http://lxingyuan.blog.chinaunix.net/uid-26969873-id-5707445.html

posted on 2016-02-07 11:57  XieSir  阅读(877)  评论(0)    收藏  举报

导航

本站采用CC授权如需转载、引用文章,请务必附上作者及来源处。 Creative Commons License