Vscode configures the C/C++ environment to report an error, which makes it impossible to run the code. The error is as follows:

Vscode configures the C/C++ environment to report an error, which makes it impossible to run the code. The error is as follows:

Problem description—gcc: The item 'gcc' is not recognized as the name of a cmdlet, function, script file, or executable program. Please check the spelling of the name, and if a path is included, make sure it is correct and try again. Location Line: 1 Character: 1 + gcc .\hello.c + ~~~ + CategoryInfo : ObjectNotFound: (gcc:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Error message:

gcc : The item 'gcc' is not recognized as the name of a cmdlet, function, script file, or executable program. Please check the spelling of the name, if including the path

problem causes

Vscode does not run the code as an administrator

Solution

By locating the cause of the problem, first check whether it is the cause of the C/C++ environment compiler:

image.png

It is found that there is no problem with the environment, that is, running the code on vscode is unsuccessful, but the cmd window runs successfully

Finally, it was found that it was a problem with the vscode software. Finally, right-click the vscode property and choose to run as an administrator to successfully output it.

image.png

Restart vscode, run

image.png

image.png

No error reported, successful operation, for convenience, you can install the code running plug-in for simplified operation, without terminal operation

Code Runner plug-in: run code with one click, support more than 40 languages.

image.png

After installing this plug-in, you can place the mouse on the code file and click the right mouse button to see

image.png

Click to run the code, you can also run the shortcut key, the code runs successfully, which is much more convenient

image.png

Guess you like

Origin blog.csdn.net/Deng872347348/article/details/131361593