【问题标题】:failed execute of devc++ programdevc++程序执行失败
【发布时间】:2019-02-25 22:49:44
【问题描述】:

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

错误 193:它不是一个有效的 win32 应用程序。

我不知道问题出在哪里。

对于 C 中的 prog,代码块是否比 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();

}

【问题讨论】:

  • 你在dev-c++里面的编译参数是什么?
  • 如果不喜欢dev-c++,可以下载使用Visual Studio。这是关于如何在 VS 上进行纯 C 编程的一点 tutorial
  • @Simo VS 不是符合标准的 C 编译器。我不会推荐它。
  • @Simo 因为它直接来自微软。他们不关心遵循标准。此外,MS 专注于 C++,并且大部分都放弃了对编译器 C 模式的支持,尽管尝试了一些更新,但它仍然非常过时。
  • @Simo 不是意见,而是事实。符合标准的 C 程序无法在 VS 上编译。可以在gcc、clang、icc等上编译。

标签: c codeblocks dev-c++


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    相关资源
    最近更新 更多