【发布时间】: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++