大家帮我看看这个程序错误在哪?怎么改呢?#include "stdio.h"#include "malloc.h"#include "windows.h"typedef struct _Node{ char name[6]; char tel[8]; struct _Node *next;}Node,*List;void InitNode(List L){ if((L=(List)malloc(sizeof(Node)))=
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 08:51:18
大家帮我看看这个程序错误在哪?怎么改呢?#include "stdio.h"#include "malloc.h"#include "windows.h"typedef struct _Node{ char name[6]; char tel[8]; struct _Node *next;}Node,*List;void InitNode(List L){ if((L=(List)malloc(sizeof(Node)))=
大家帮我看看这个程序错误在哪?怎么改呢?
#include "stdio.h"
#include "malloc.h"
#include "windows.h"
typedef struct _Node
{
char name[6];
char tel[8];
struct _Node *next;
}Node,*List;
void InitNode(List L)
{
if((L=(List)malloc(sizeof(Node)))==NULL)
exit(-1);
L->next=NULL;
}
void AddNode(List L)
{
if((List p=(List)malloc(sizeof(Node)))==NULL)
exit(-1);
printf("Input Name:\n")
scanf("%s",p->name);
printf("Input Tel:\n")
scanf("%s",p->tel);
List p1=L->next,p2=L;
while(p1->next && strcmp(name,p->name)>0)
{
p1=p1->next;
p2=p2->next;
}
p->next=p2->next;
p1->next=p;
}
void PrintNode(List L)
{
List p=L->next;
while(p)
{
printf("name: %s\t\tTel: %s\n",p->name,p->tel);
p=p->next;
}
}
void main()
{
List L;
InitNode(L);
for(int i=0;i
大家帮我看看这个程序错误在哪?怎么改呢?#include "stdio.h"#include "malloc.h"#include "windows.h"typedef struct _Node{ char name[6]; char tel[8]; struct _Node *next;}Node,*List;void InitNode(List L){ if((L=(List)malloc(sizeof(Node)))=
很多分号没打
exit函数没有定义
while(p1->next && strcmp(name,p->name)>0) name是哪个节点的数据没有指明
改了一下~lz试调一下
#include "stdio.h"
#include "malloc.h"
#include "windows.h"
typedef struct _Node
{
char name[6];
char tel[8];
struct _Node *next;
}Node,*List;
void InitNode(List L)
{
if((L=(List)malloc(sizeof(Node)))==NULL)
exit(-1);
L->next=NULL;
}
void AddNode(List L)
{
List p=(List)malloc(sizeof(Node));
if(p==NULL)
{
printf("Error!\n");
return;
}
printf("Input Name:\n");
scanf("%s",p->name);
printf("Input Tel:\n");
scanf("%s",p->tel);
List p1=L->next,p2=L;
while(p1->next && strcmp(p1->name,p->name)>0)
{
p1=p1->next;
p2=p2->next;
}
p->next=p2->next;
p1->next=p;
}
void PrintNode(List L)
{
List p=L->next;
while(p)
{
printf("name:%s\t\tTel:%s\n",p->name,p->tel);
p=p->next;
}
}
void main()
{
List L;
InitNode(L);
for(int i=0;i