1. Download VScode (skip to step five after installation)
Official website download: https://code.visualstudio.com/
2. Install VScode
1. Open the installation package and click to agree to this agreement, next step.
2. Select the installation location and click next.
3. Create program shortcut, default settings, next step.
4. Choose additional tasks according to your needs.
5. Start installation
6. Complete installation
3. VScode sets the language to Chinese
1. Press the shortcut key Ctrl+Shift+P, enter extensions in the box that appears, and press Enter. (You can also click the 5th icon on the left navigation bar to enter the download)
2. Enter Chinese to install Chinese Simplified (Traditional).
3. Restart the software and it will change to Chinese.
4. VScode switching theme (personal preference)
Press Ctrl+K, then Ctrl+T to select your favorite theme switch.
5. Download the C language compiler (MinGW-W64 GCC)
Link: https://pan.baidu.com/s/1zBO37-yEkW54vBLOsp1kgA
Extraction code: wo9n
6. Configure compiler environment variables
1. Unzip the compressed package, find a folder called bin in the folder, and copy the folder address (right-click the folder address to find the copy address).
Right-click this computer, click Settings, enter the settings interface, find Advanced System Settings, and click to enter.
2. Enter the environment variables.
3. In the system variables in the environment variables, find the Path variable, double-click to open it, add the address you just copied, and then click OK.
4. Finally, test whether the environment configuration is successful. Press Win key + R to open the run window, enter cmd, press Enter, and enter in the command line window. gcc -v -E -x c++ -
If the running result is as follows, the configuration is successful.
7. Configure VScode
1. Click the 5th icon in the left navigation bar, enter C, and install.
2. Create a new folder as a C language project file. Open this folder, Ctrl+N, and create a new hello.c file (name it as you like, just end with .c).
3. Enter the program test in the hello.c file created previously.
#include<stdio.h>
int main()
{
printf("hello world\n");
return 0;
}
4. When you start the program (you can press F5 directly),
the following options will pop up. Select the first one
and then generate the configuration file.
At this time, a .vscode folder will be automatically generated. If you run the .c file again, you will find that the output in the terminal has been successful.
8. Use a separate window to output the results
Some students want to output the results in a separate window. Find launch.json
, "externalConsole": false
change it to "externalConsole": true
, and save. At this time, the console will crash. Add getchar();
the .c file to the code and it should be as follows.
#include <stdio.h>
int main ()
{
printf("HelloWorld\n");
getchar();
return 0;
}
Or add it to the code system("pause");
and press any key to proceed to the next step. Pay attention to adding the header file #include <stdlib.h>
. At this time, the .c file should be as follows
#include <stdio.h>
#include <stdlib.h>
int main ()
{
printf("HelloWorld\n");
system("pause");
return 0;
}
9. Several useful VScode plug-ins
All plug-ins can be installed by clicking the 5th icon (Extension) on the left navigation bar
name | effect |
---|---|
Path Intellisence | Path autocomplete |
Bracket Pair Colorizer 2 | Highlight matching brackets with different colors |
vscode-fileheader | Top comment template, customizable information, automatic update of the last modification time |
markdownlint | Grammar error correction |
Beautify | Format code |
Code Spell Checker | Identify misspelled words |
10. VSCode sets mouse scrolling to change font size
If you open it for the first time, you need to use Ctrl+Shift+P to open the search box, enter settings.json, press Enter to open and join "editor.mouseWheelZoom": true
. (After opening it once, Ctrl+P can search)