解决Code::blocks中文乱码的问题,并支持C++11特性
一、设置编辑环境可以使用中文:
Settings -> Editor... -> Encoding settings
Use encoding when opening files 设置为 UTF-8
二、编译为中文程序:
Settings -> Compiler... -> Other compiler options
大陆用户在框内加上 -fexec-charset=GBK ,台湾用户加 -fexec-charset=BIG-5 。(Windows 10 直接支持命令提示符下显示 UTF-8字符,所以这个可以不必设置)
或者
将 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”
即可。
测试代码:
#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
浙公网安备 33010602011771号