gpt4 book ai didi

c - devc++程序执行失败

转载 作者:行者123 更新时间:2023-11-30 20:09:26 26 4
gpt4 key购买 nike

我已经在 devc++ 上编译了它,它返回了此消息

ERROR 193 : it isn't a win32 valid application.

我无法弄清楚问题出在哪里。

对于 C 语言来说,代码块比 devc++ 更好吗?因为我主要发现 devc++ 的问题,所以请告诉我问题是什么以及为什么我不能用 devc++ 编译它

/* Doubly Linked List implementation */
#include<stdio.h>
#include<stdlib.h>

struct Node {
int data;
struct Node* next;
struct Node* prev;
};

struct Node* head; // global variable - pointer to head node.

//Creates a new Node and returns pointer to it.
struct Node* GetNewNode(int x) {
struct Node* newNode
= (struct Node*)malloc(sizeof(struct Node));
newNode->data = x;
newNode->prev = NULL;
newNode->next = NULL;
return newNode;
}

//Inserts a Node at head of doubly linked list
void InsertAtHead(int x) {
struct Node* newNode = GetNewNode(x);
if(head == NULL) {
head = newNode;
return;
}
head->prev = newNode;
newNode->next = head;
head = newNode;
}

//Inserts a Node at tail of Doubly linked list
void InsertAtTail(int x) {
struct Node* temp = head;
struct Node* newNode = GetNewNode(x);
if(head == NULL) {
head = newNode;
return;
}
while(temp->next != NULL) temp = temp->next; // Go To last Node
temp->next = newNode;
newNode->prev = temp;
}

//Prints all the elements in linked list in forward traversal order
void Print() {
struct Node* temp = head;
printf("Forward: ");
while(temp != NULL) {
printf("%d ",temp->data);
temp = temp->next;
}
printf("\n");
}

//Prints all elements in linked list in reverse traversal order.
void ReversePrint() {
struct Node* temp = head;
if(temp == NULL) return; // empty list, exit
// Going to last Node
while(temp->next != NULL) {
temp = temp->next;
}
// Traversing backward using prev pointer
printf("Reverse: ");
while(temp != NULL) {
printf("%d ",temp->data);
temp = temp->prev;
}
printf("\n");
}

int main() {

/*Driver code to test the implementation*/
head = NULL; // empty list. set head as NULL.

// Calling an Insert and printing list both in forward as well as reverse direction.
InsertAtTail(2); Print(); ReversePrint();
InsertAtTail(4); Print(); ReversePrint();
InsertAtHead(6); Print(); ReversePrint();
InsertAtTail(8); Print(); ReversePrint();

}

最佳答案

如果我懂法语,您遇到的问题是编译的程序不是有效的 Win32 应用程序。这可能只是因为您选择了 Windows 项目,但提供了 int main() 而不是 WinMain。这应该是一个控制台应用程序项目。

如果这不是原因,我会怀疑一些与编程无关的原因,例如链接时运行可执行文件、造成严重破坏的防病毒程序、用户访问权限等。

DevC++ 不再维护,因此它包含旧版本的 gcc/g++ 编译器。所以我强烈推荐Codeblocks,因为它可以使用最新版本的编译器。总体而言,它也是一个更强大的 IDE,并且由于它还可以干净地编译代码,因此没有理由坚持使用 DevC++。

关于c - devc++程序执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52445211/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com