c++ - 我的代码是正确的,但它不能在我的 vscode 上运行
问题描述
#include<iostream>
using namespace std;
struct node{
int data;
struct node *next;
}*first;
void create(int a[],int n)
{
int i;
struct node *t, *last;
first = new struct node;
first->data = a[0];
first->next = NULL;
last=first;
for (i=1;i<n;i++){
t=new node;
t->data=a[i];
t->next=NULL;
last->next=t;
last=t;
}
}
void display(struct node *p){
while(p!=NULL){
cout<<p->data<<" ";
p=p->next;
}
}
int main(){
int A[] = {3,5,7,10,15};
create(A,5);
display(first);
}
错误信息:
Program 'Node.exe' failed to run: Access is deniedAt line:1 char:83
+ ... inked lists\" ; if ($?) { g++ Node.cpp -o Node } ; if ($?) {
.\Node }
+
~~~~~~.
At line:1 char:83
+ ... inked lists\" ; if ($?) { g++ Node.cpp -o Node } ; if ($?) {
.\Node }
+
~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [],
ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
这是运行代码后显示的错误。在我运行任何程序后,.exe
会创建一个文件,但在这里该.exe
文件被我的防病毒软件删除,因为它说它是一个特洛伊木马......
如果我在在线编译器中运行代码,它会完美运行
解决方案
如果您只想编译和运行,您可以这样做
g++ Node.cpp -o Node ; .\Node
如果你想确保程序在编译错误的情况下不运行,你可以这样做g++ Node.cpp -o Node && .\Node
如果这些不起作用,请尝试在管理模式下运行这些命令
另外您的命令不清楚请重新发布您的完整命令或发布命令行截图
推荐阅读
- python - asyncio 在多个工作人员中从同步功能运行
- python-3.x - 使用 Pandas Python 读取 csv 并将其格式化为字典
- c# - 在 Microsoft Graph API 中更新/删除“此事件和所有后续事件”
- python - 基于一维索引数组将一维数组的值添加到二维数组
- javascript - Google Drive API 出现奇怪的 CORS 问题
- hive - 插入覆盖不会删除所有旧数据文件
- python - 我怎样才能使我的字符串搜索正确,因为它只显示第一次命中?
- crystal-reports - SAP Crystal Report 显示数据库连接器错误:
- google-cloud-platform - GCP 上的 BACKEND_SERVICES 配额限制为 5
- api - WebUSB 和 WebSerial 之间的区别