VSCode configures C language environment (detailed tutorial)

1. Install the C/C++ plug-in and C/C++ Extension Pack plug-in in VSCode

Insert image description here
Insert image description here

2. Download mingw64

Mingw64 official website web link
1. Find downloads
2.Insert image description here
Find SourceForge
Insert image description here
3. Find a suitable version (here I pulled down to find the installation-free version) to download. I have tried others, but they don’t work (maybe It is because the connection to the external network is unstable)
Insert image description here
4. Extract directly to the desired location
Insert image description here
5. Add mingw64 to the environment variable
and extract the downloaded mingw64 to the specified directory. My path is C:\Program Files\mingw64, Then configure the environment variables and add the directory C:\Program Files\mingw64\bin to the environment variable path (note to change it to your own mingw64 path, specifically to the bin folder). Open the command line and enter gcc -v. The following information appears to explain the mingw64 configuration
Insert image description here
. Success, then you need to restart VSCode
Insert image description here

3. Detailed tutorial on running and debugging C language programs

Run C language program

1. Create a folder arbitrarily for writing C programs

  • Create test.c file to test whether the c language environment is configured successfully
#include <stdio.h>
 
int main()
{
    
    
   printf("Hello, World! \n");
 
   return 0;
}

Insert image description hereInsert image description here
Insert image description here
The appearance of the above interface indicates that the C language environment configuration is successful!

Compile and run c program in command line window
Insert image description here
Insert image description here

Insert image description here

Debugging C language programs

  • Debugging Tutorial: Give a break point at a certain location for debugging (you control whether the program executes the next step)

Test code:

#include <stdio.h>
 
int main()
{
    
    
    for (int i = 0; i < 10; i++)
    {
    
    
        printf("Hello, World! \n");
    }

   return 0;
}

Insert image description here
Insert image description here

  • The above is the tutorial for configuring the C language environment, running and debugging C programs in VSCode. If the configuration is successful, please give a little star (hahaha~)

Note: 如果执行 C 程序输出中文乱码,请看下面这篇文章
vscode solves the problem of c language printf printing Chinese garbled characters

Guess you like

Origin blog.csdn.net/weixin_61370021/article/details/132597400
Recommended