在终端中执行用户输入文件时,VS 代码访问被拒绝 [英] VS code access denied when executing user input file in terminal
问题描述
这是我到目前为止所尝试的,但是在运行程序后,这显示了一些错误;
Here is what i tried so far, but after running the program, this shows some error;
#include <stdio.h>
#include <stdlib.h>
int main(){
int number;
printf("Enter the number:");
scanf("%d",&number)
printf("The number is %d",number);
return 0;
}
但是当我运行程序时它显示了这个错误
but when I ran the program it shows me this error
Program 'hello.exe' failed to run: Access is deniedAt line:1 char:59
+ cd "d:\c\" ; if ($?) { gcc hello.c -o hello } ; if ($?) { .\hello }
+ ~~~~~~~.
At line:1 char:59
+ cd "d:\c\" ; if ($?) { gcc hello.c -o hello } ; if ($?) { .\hello }
+ ~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
推荐答案
我有同样的问题.有几种情况可能会导致此错误.
I have the same problem. There are a couple of things that may cause this error.
MinGW 未正确安装.如果没有安装,请正确安装.单击 here.
如果您的代码不涉及从用户那里获取任何输入并正确给出输出,并且它显示访问被拒绝"当代码需要用户输入时,可能是由于您使用的防病毒软件.我有同样的问题,我发现我的防病毒软件McAfee"无法运行.导致这个问题,我卸载了它.代码完美运行.但是 Windows Defender 不会导致这个问题,因此我现在使用 Windows Defender 来保护我的电脑.如果您不信任 Windows Defender,并且您确实认为您现在使用的防病毒软件是必要的,请不要这样做.
If your code doesn't involve taking any input from the user and giving the output properly, and it says "access denied" when the code requires user input, it is probably due to the antivirus you are using. I have the same problem, I discovered that my antivirus "McAfee" caused this problem and I uninstalled it. The code worked perfectly. But Windows Defender doesn't cause this problem, hence I am now using Windows Defender to protect my pc. If you don't trust Windows Defender and you really think that the antivirus you are using now is necessary, don't go for this.
这篇关于在终端中执行用户输入文件时,VS 代码访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!