0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C言語のコンパイル時に文字化けが発生する

0
Posted at

この記事は過去のエラー解決メモを整理したものです。
現在の推奨手順とは異なる可能性があります。
公式ドキュメントを確認して最新情報と差分がないかを確認してください。

事象

VSCode上でC言語のプログラムをコンパイルして実行したところ、出力された日本語が文字化けした。

Microsoft Windows [Version 10.0.19043.1237]
(c) Microsoft Corporation. All rights reserved.

D:\programs>cd "d:\programs\workspace\c_c++\" && gcc exa.c -o exa && "d:\programs\workspace\c_c++\"exa
C險隱槭・鄙偵≧繧医j諷」繧後h

d:\programs\workspace\c_c++>

環境

  • Windows 10
  • VSCode 1.61.2
  • GCC
  • Code Runner

原因

Windowsのコンソールと実行環境の文字コードが一致していなかったため。

対策

Code Runnerの設定を変更する。

  • Code Runnerをターミナルで実行する設定に変更する。
  • settings.json-fexec-charset=CP932 を追加する。

参考情報

C++の日本語文字化けについて【初心者です】|teratail

Visual Studio CodeでC言語プログラミングを始める(Windows編)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?