MinGW編譯c++,中文顯示亂碼解決方案
阿新 • • 發佈:2019-01-05
我比較喜歡MinGW,現在使用的是
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)
編輯器是微軟的VS code ,今天在win10上剛搭好環境,直接在VS code寫了一個c++測試檔案,雖然編譯未報錯,但是中文顯示亂碼了。
查閱了很多位熱心博主的博文,都是要我去修改profile和inputrc.default,然而結果顯示並沒有什麼用,也不知道是什麼錯了。
後來仔細檢視MinGW發現,
windows上的中文編碼是GBK
將cpp檔案從utf-8改為gbk編碼方式,中文就可以顯示了,真是呵呵了!!
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
請按任意鍵繼續. . .