我写了3个文件main.c list.c pub.h
main.c:
#include <stdio.h>
#include <malloc.h>
#include "pub.h"
int main()
{
struct student *head1,*head2;
head1 = creat();
head2 = creat();
destroy(head1);
destroy(head2);
getchar();
return 1;
}
list.c:
#include <stdio.h>
#include <malloc.h>
#include "pub.h"
struct student *creat()
{
struct student head;
struct student *p;
int num;
float scroe;
head.next = NULL;
scanf("%d,%f",&num,&scroe);
while(num != 0)
{
p = (struct student *)malloc(LEN);
if(p == NULL)
{
printf("memory is not enough!\n");
break;
}
p->num = num;
p->scroe = scroe;
p->next = head.next;
head.next = p;
scanf("%d,%f",&num,&scroe);
}
if(p == NULL)
{
destroy(head.next);
return NULL;
}
return head.next;
}
int destroy(struct student *head)
{
struct student *p = head;
struct student *pNext = NULL;
while(p != NULL)
{
pNext = p->next;
free(p);
p = pNext;
}
return 1;
}
pub.h
#ifndef _STULIST_H
#define _STULIST_H
struct student
{
int num;
float scroe;
struct student *next;
};
struct student *creat();
int destroy(struct student *head);
#define LEN sizeof(struct student)
#endif
(list.c中)
(main.c中)
请问这是什么原因啊,求解,谢谢!
[此贴子已经被作者于2007-9-18 23:04:19编辑过]
----------------解决方案--------------------------------------------------------
谁帮下忙啊?我看了半天,没搞懂
----------------解决方案--------------------------------------------------------
求助啊~~~~~~~~~~等了好久了
----------------解决方案--------------------------------------------------------
destroy函数没有声明??
还有,貌似你建立了错误的工程,并不是Console
by 雨中飞燕 QQ:78803110 QQ讨论群:5305909
[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url] http://yzfy.org/
----------------解决方案--------------------------------------------------------
哦,谢谢了
----------------解决方案--------------------------------------------------------