【问题标题】:VS code access denied when executing user input file in terminal在终端中执行用户输入文件时拒绝 VS 代码访问
【发布时间】:2021-01-23 05:27:23
【问题描述】:

到目前为止,这是我尝试过的,但是在运行程序后,这显示了一些错误;

#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;
}

但是当我运行程序时它显示了这个错误

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

【问题讨论】:

    标签: c visual-studio-code


    【解决方案1】:

    我也有同样的问题。有几件事可能会导致此错误。

    1. MinGW 没有正确安装。如果未安装,请正确安装。 点击here

    2. 如果您的代码不涉及从用户那里获取任何输入并正确提供输出,并且在代码需要用户输入时显示“拒绝访问”,则可能是由于您使用的防病毒软件所致。我有同样的问题,我发现我的防病毒软件“McAfee”导致了这个问题,我卸载了它。代码运行良好。但是 Windows Defender 不会导致这个问题,因此我现在使用 Windows Defender 来保护我的电脑。如果您不信任 Windows Defender,并且您确实认为您现在使用的防病毒软件是必要的,请不要这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 2014-11-11
      • 2021-03-21
      • 1970-01-01
      • 2013-07-17
      • 2015-12-01
      • 1970-01-01
      相关资源
      最近更新 更多