C Language Editor VSCode
VSCode is a personal favorite editor software. I have run three terminals simultaneously in VSCode, developing in Python, Golang, and C language. The download link is as follows:
code.visualstudio.com
Configuring MinGW in VSCode
To configure MinGW in VSCode, follow these steps:
-
Install the C/C++ extension from the extensions in VSCode;
-
Create a new folder on your computer, for example, ‘code’, to store your C language code files;
-
Select ‘File’ in VSCode and choose ‘Open Folder’ from the dropdown menu;
-
Then create a new file with a .c extension in that folder, for example, hello.c, and enter the code below;
-
Double-click the hello.c file to enter edit mode, press the shortcut key ‘ctrl+shift+p’, and a dropdown menu will appear in the search box at the top of VSCode;
-
Type ‘C/C++’ in the search box and select ‘C/C++: Edit Configurations (UI)’;
-
In the popped-up C/C++ configuration, find ‘Compiler Path’ and enter the path of gcc.exe in your installed MinGW, usually found in the bin folder (you may need to manually enter this path);
-
Below ‘Compiler Path’, find ‘IntelliSense Mode’ and change ‘${default}’ to gcc-x64(legacy);
-
Select the hello.c file, then from the terminal menu in the toolbar, select ‘Configure Tasks’, and VSCode will automatically create a tasks.json file;
-
Restart VSCode;
-
In the terminal menu of VSCode, select ‘New Terminal’ and navigate to the directory where the hello.c file is located. You can use the cd command. If the terminal already shows the current directory as this folder, for example: PS D:\c\code>, then no action is needed;
-
Enter the command: gcc hello.c -o hello. This command compiles the hello.c file and generates a file named hello, usually an exe;
-
Run the hello.exe command: ./hello.exe; if the terminal outputs: hello, world, it means the run was successful!
The code in hello.c file:
#include <stdio.h> main(){printf("hello, world\n");}
Disclaimer: This content is for reference only and does not guarantee accuracy!