MinGW compiles c++, Chinese display garbled solution

I prefer MinGW, now I use

C:\WINDOWS\system32>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=a:/mingw/bin/../libexec/gcc/mingw32/5.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-5.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads=posix --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: posix
gcc version 5.3.0 (GCC)

The editor is Microsoft's VS code. Today, I just set up the environment on win10. I wrote a c++ test file directly in VS code. Although the compilation did not report an error, the Chinese display is garbled.
I checked the blog posts of many enthusiastic bloggers, and they all asked me to modify the profile and inputrc.default, but the results showed that it was useless, and I don’t know what was wrong.
Later, I checked MinGW carefully and found
that the Chinese encoding on windows was GBK.
The cpp file was changed from utf-8 to gbk encoding, and the Chinese could be displayed, really haha! !

Microsoft Windows [版本 10.0.14393]
(c) 2016 Microsoft Corporation。保留所有权利。

A:\MinGW\1\tree>run.bat

A:\MinGW\1\tree>g++ BinaryTree.cpp -o debug/BinaryTree

A:\MinGW\1\tree>cd debug

A:\MinGW\1\tree\debug>binarytree
建立排序二叉树顺序:
7 4 2 3 15 35 6 45 55 20 1 14 56 57 58
二叉树节点个数: 15
二叉树叶子个数:6
二叉树中度数为1的结点的数量为:4

先序遍历序列:
7 4 2 1 3 6 15 14 35 20 45 55 56 57 58

中序遍历序列:
1 2 3 4 6 7 14 15 20 35 45 55 56 57 58

后序遍历序列:
1 3 2 6 4 14 20 58 57 56 55 45 35 15 7
请按任意键继续. . .

Guess you like

Origin blog.csdn.net/u014377853/article/details/52801277