Home >Development Tools >VSCode >The header file cannot be read when vscode compiles and runs a c++ program
Prerequisite: Install vs code and MinGW, and configure MinGW's environment variables.
Solution:
1. Open the C configuration file of vs code
Use the shortcut key ctrl shift p to open the search bar and enter C
Open the icon configuration file
Add the header file in the include folder in the MinGW directory, such as: "C:/MinGW/ include/**"
Then add the folder name at the end of the previous picture to the C configuration file
It should be noted that The copied file directory contains forward slashes and backslashes. You need to change all \backslashes to forward slashes.
For example: c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c
is changed to
c: /mingw/bin/../lib/gcc/mingw32/4.6.2/include/c
All file directories have double quotes "" with English punctuation at both ends, if not , an error may be reported.
After adding it, it will look like this:
Remember to save after making changes. At this time, enter #include stdio.h and no error will be reported.
Recommended related articles and tutorials: vscode tutorial
The above is the detailed content of The header file cannot be read when vscode compiles and runs a c++ program. For more information, please follow other related articles on the PHP Chinese website!