链表帮忙查下错

来源:百度知道 编辑:UC知道 时间:2024/05/26 05:01:04
/*******************************************************/
/*一个双链表
*/
/*******************************************************/

#include<stdio.h>
#include<stdlib.h>

struct node
{
struct node *prior;
int num;
struct node *next;
}*head,*p,*tail,*temp;

struct node *Creat(void)
{
printf("The Creat \n");
p=(struct node*)malloc(sizeof(struct node));
return p;
}

void Insert() // 顺序插入
{
/*******************************************************/
/*先存储在临时指针中 */
/*******************************************************/
int i;
printf("Insert function is done\n"); //测试函数是否被调用
printf("Input the num\n");

fflush(stdin);
scanf("%d",&temp->num);
/*******************************************************/
if(p==head->next

呵呵,注意一下,C/C++语言是区分大小写的,也就是说大写和小写不能混用

void main()
{
head=Creat();
Insert(); //子函数声明为Insert,所以需要将原先的insert改为Insert
Insert(); //子函数声明为Insert,所以需要将原先的insert改为Insert
list(head);
}

Insert(); //子函数声明为Insert,所以需要将原先的insert改为Insert
Insert(); //子函数声明为Insert,所以需要将原先的insert改为Insert

temp这个指针没有初始化就拿来用了啊,搞毛啊
看楼主的目的好像是temp=head,在main里面加上吧
都是用的全局变量,代码可读性太差了
很危险的代码

Insert 要大写
你用全局变量貌似很容易出错啊!