c - devc++程序执行失败

标签 c codeblocks dev-c++

我已经在 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/

相关文章:

c - 读取整数数组并将其打印出来

c - atol() 与 strtol()

c++ - 如何让VS变得便携

c++ - 为什么我的程序运行完后窗口立即消失了?我怎样才能让它留在身边?

c - 如何在 wine (Ubuntu) 上制作 Dev C++ 编译后自动启动

c - 使用 C 中的子例程对并行数组进行排序的最佳或最有效的方法?

c++ - 使用 SVD 分解的图像重建

c++ - 在 debian 中安装 boost(用于 Codeblocks)

c++ - CodeBlocks 代码在 Visual Studio 中不起作用

c++ - dev-cpp 和 Microsoft Visual C++ math.h 的区别