Configuring C Language Learning Environment in Vscode – Text Tutorial

Download the compressed package below:

mingw-w64.zip (If you need the compressed package, please leave a message, and I will reply with the download link)

Extract the compressed package:

Configuring C Language Learning Environment in Vscode - Text Tutorial

Copy this folder to the C:\Program Files directory:

Configuring C Language Learning Environment in Vscode - Text TutorialConfiguring C Language Learning Environment in Vscode - Text Tutorial

Click on the bin folder under the mingw-w64 folder and copy the path:

Configuring C Language Learning Environment in Vscode - Text Tutorial

C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin

Configure environment variables:

Right-click on This PC, and select Properties.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Search for environment variables and select Edit environment variables.

Configuring C Language Learning Environment in Vscode - Text Tutorial

In the pop-up System Properties dialog, select the Environment Variables (N) option.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Edit the environment variables:

Configuring C Language Learning Environment in Vscode - Text TutorialConfiguring C Language Learning Environment in Vscode - Text Tutorial

Copy the previously obtained bin path into the newly created environment variable.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Verify the compiler:

Create a folder for storing the C files we will learn next.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Open Vscode, select our C folder, create a new C file, and double-click to open it.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Input the following code:

#include <stdio.h>
int main()
{
    printf("hello BldEleK !!");
    return 0;
}

Configuring C Language Learning Environment in Vscode - Text Tutorial

Click the triangle symbol in the upper right corner to run the code:

Configuring C Language Learning Environment in Vscode - Text Tutorial

Finally, we need to configure Vscode to support the scanf input function for C language:

In the upper left corner, go to File – Preferences – Settings:

Configuring C Language Learning Environment in Vscode - Text Tutorial

Type RunInTerminal in the search box,

Configuring C Language Learning Environment in Vscode - Text Tutorial

Let’s verify the input function:

Modify the previous example code as follows.

#include <stdio.h>
int main()
{
    char a;
    scanf("%d", &a);
    printf("The number you entered is :%d", a);

    return 0;
}

Run the code.

You can see that the output is garbled.

Configuring C Language Learning Environment in Vscode - Text TutorialConfiguring C Language Learning Environment in Vscode - Text Tutorial

The solution is as follows.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Select GB2312.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Even after selecting GB2312, it is still garbled.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Press Ctrl+Z, and the Chinese characters in the code will display correctly.

Configuring C Language Learning Environment in Vscode - Text Tutorial

Everyone can click to run the output of Chinese characters a few times to display normally.

Configuring C Language Learning Environment in Vscode - Text Tutorial

If the above verification is OK, the following reference materials can be ignored; our main focus is to learn C language.

Reference materials:

https://blog.csdn.net/m0_67446994/article/details/140244943

MinGW official website:

https://sourceforge.net/projects/mingw/files/

https://blog.csdn.net/qq_41885673/article/details/115353394

Leave a Comment