这次编译通过了,汗~

alamelpf 2005-11-18 10:31:59
#include<stdio.h>
#define MAXSIZE 100
#define NULL 0
typedef struct node
{char data;
struct node *next;
}Node,*Linklist;
/*****************************************************************************/
Linklist Create() //用头插法创建链表
{int flag=1;
Linklist head;
Node *s;
char c;
head=(Linklist)malloc(sizeof(Node));
head->next=NULL;
while(flag)
{c=getchar();
if(c!='$')
{s=(Node *)malloc(sizeof(Node));
s->data=c;
s->next=head->next;
head->next=s;
}
else flag=0;
}
return(head);
}
/*****************************************************************************/
main()
{int i=0,j=1; //创建链表进行插入,删除,查找,查找并且插入数据,显示等操作
char key,b;
Linklist head;
printf("请先给链表进行初始化!完毕后用$结束\n");
head=Create();
printf("请输入您所要进行的操作!\n");
while(j)
{printf("1.插入 2.删除 3.查找 4.查找并且插入数据 5.显示全部链表数据 6.退出\n");
scanf("%d",&i);
//if(i==1) //插入
//test1();
//if(i==2) //删除
//test2();
// if(i==3) //查找
// test3();
if(i==4) //查找并插入数据
{printf("请输入你所要查找的数据!\n");
key=getchar();
printf("请输入你所要插入的数据!\n");
b=getchar();
test4(head,key,b);
}
if(i==5) //显示
test5(head);
if(i==6)
break;
}
}
/************* *************************************************************/
test4(Linklist head,char key,char b)
{Linklist p,q;
p=head->next;
while(p!=NULL)
if(p->next->data!=key)
p=p->next;
else break;
q=(Linklist)malloc(sizeof(Node));
q->data=b;
q->next=p->next;
p->next=q;
}
/**************************************************************************/
test5(Linklist head)
{Linklist l;
l=head->next;
while(l->next!=NULL)
{printf("%c ",l->data);}
printf("\n");
}
...全文
84 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
逸学堂 2005-11-18
  • 打赏
  • 举报
回复
至于第一个问题
E:\学习\c语言\test.c(14) : warning C4013: 'malloc' undefined; assuming extern returning int
注意包含文件
包含
#include <alloc.h>
或者
#include <stdlib.h>
这样才可以使用
lzp229 2005-11-18
  • 打赏
  • 举报
回复
你怎么又开了,刚才那个里面说的错误也没有修正。开帖要结帖给分的,分要省点用
逸学堂 2005-11-18
  • 打赏
  • 举报
回复
test4(Linklist head,char key,char b)
test5(Linklist head)
注意改成这样,如果无返回值
void test4(Linklist head,char key,char b)
void test5(Linklist head)
alamelpf 2005-11-18
  • 打赏
  • 举报
回复
有很多警告
什么意思啊
test.c
E:\学习\c语言\test.c(14) : warning C4013: 'malloc' undefined; assuming extern returning int
E:\学习\c语言\test.c(50) : warning C4013: 'test4' undefined; assuming extern returning int
E:\学习\c语言\test.c(53) : warning C4013: 'test5' undefined; assuming extern returning int
E:\学习\c语言\test.c(70) : warning C4716: 'test4' : must return a value
E:\学习\c语言\test.c(78) : warning C4716: 'test5' : must return a value
Linking...

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧