c语言问题——为什么一下程序可以通过编译却无法运行?DEV-c++编译器的

#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "alloc.h"
typedef struct node
{
int data;
struct node *next;
}NODE;
main()
{
NODE *head=NULL,*q;
int i;
for(i=0;i<10;i++)
{
q=(NODE*)malloc(sizeof(NODE));
scanf("%d",&q->data);
q->next=head;//从表头插入节点
head=q;
}
printf("链表遍历\n");
q=head;
while(q!=NULL)
{if(q->next!=NULL)
printf("%d->",q->data);
else
printf("%d",q->data);
q=q->next;
}
getch();//输入代码
}
显示如下——
\Documents and Settings\Administrator\My Documents\link.c C:\Documents and Settings\Administrator\My Documents\C alloc.h: No such file or directory.

通过编译,却无法链接或者运行,是因为有该文件的申明,却没有该申明的Lib或者Dll或者源码。
解决方案:
1.在DEV中Link选项中默认添加alloc.c 或者 alloc.lib
2.在工程文件中添加alloc.c或者alloc.lib
3.选着包含malloc的声明文件,一般应该在malloc.h中
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-06-05
你的头文件有错误:修改如下
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "malloc.h"\\此处有修改
typedef struct node
{
int data;
struct node *next;
}NODE;
main()
{
NODE *head=NULL,*q;
int i;
for(i=0;i<10;i++)
{
q=(NODE*)malloc(sizeof(NODE));
scanf("%d",&q->data);
q->next=head;//从表头插入节点
head=q;
}
printf("链表遍历\n");
q=head;
while(q!=NULL)
{if(q->next!=NULL)
printf("%d->",q->data);
else
printf("%d",q->data);
q=q->next;
}
getch();//输入代码
}本回答被网友采纳
第2个回答  2011-06-05
去掉#include "alloc.h"就可以了
第3个回答  2011-06-05
先搜索DEVC++安装目录下有没有alloc.h文件
相似回答