求助;syntax error before“int”

AVE缌念 2013-05-26 04:44:08
void main()
{
outputlink();
insert(int x,int y);
delectlink(int x);
printf("第一次扫描输出:\n");
outputlink();
insert(10,10);
insert(10,20);
insert(10,30);
insert(40,40);
printf("\n第二次扫描输出:\n");
outputlink();
delectlink(30);
delectlink(50);
printf("\n第三次扫描输出:\n");
outputlink();
}
红色的那一行出错哦,不过我感觉没错啊,就是看不出来。
...全文
300 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
闭着眼刷牙 2013-05-28
  • 打赏
  • 举报
回复
引用 6 楼 AnYidan 的回复:
[quote=引用 2 楼 hugett 的回复:] 你的函数声明没有返回类型。。
++[/quote]++
AnYidan 2013-05-26
  • 打赏
  • 举报
回复
引用 2 楼 hugett 的回复:
你的函数声明没有返回类型。。
++
AVE缌念 2013-05-26
  • 打赏
  • 举报
回复
[quote=引用 3 楼 max_min_ 的回复:] [code=c]int main() // main 函数最好 给返回值,不要用void了,不要相信谭浩强的书的了, 恩恩,现在老师这么教的,才学了不久
AVE缌念 2013-05-26
  • 打赏
  • 举报
回复
还是全贴上来吧 #include<stdio.h> #include<stdlib.h> struct node *head; struct node { int d; struct node *next; } void outputlink() //扫描链表 { struct node *p; if(head==NULL) { printf("链表为空,无法输出!"); return; } p=head; while(p!=NULL) { printf("%4d",p->d); p=p->next; } } void insert(int x,int y) //在链表中x前插入一个数y { struct node *p,*q; q=malloc(sizeof(struct node)); q->d=y; if(head==NULL) { head=q; return; } if(head->d==x) { q->next=head; head=q; return; } p=head; while(((p->next)->d!=x)&&(p->next!=NULL)) p=p->next; q->next=p->next; p->next=q; } void delectlink(int x) //在链表中删除x { struct node *p; if(head==NULL) { printf("链表为空,无法删除!\n"); return; } if(head->d==x) { head=head->next; return; } p=head; while(p->next!=NULL&&(p->next)->d!=x) p=p->next; if(p->next==NULL) { printf("表中无此元素,无法删除!"); return; } p->next=(p->next)->next; printf("删除数为%d\n",x); } void main() { void outputlink(); void insert(int x,int y); void delectlink(int x); head=NULL; printf("第一次扫描输出:\n"); outputlink(); insert(10,10); insert(10,20); insert(10,30); insert(40,40); printf("\n第二次扫描输出:\n"); outputlink(); delectlink(30); delectlink(50); printf("\n第三次扫描输出:\n"); outputlink(); } 在outputlink()前加void就会出现错误 two or more data types in declaration of outputlink 要是不加void程序无错误,但运行出现了乱码,这是怎莫回事啊??
max_min_ 2013-05-26
  • 打赏
  • 举报
回复
int main() // main 函数最好 给返回值,不要用void了,不要相信谭浩强的书的了, 
{
	//函数的申明,也就是函数的原型了,没有返回类型是不完整的 
	//outputlink();
	void outputlink();
	//insert(int x,int y);
	void insert(int x,int y);
	//delectlink(int x);
	void delectlink(int x);// 从你的代码思路看, 你的函数返回类型应该都是void 
	
	printf("第一次扫描输出:\n");
	outputlink();
	
	insert(10,10);
	insert(10,20);
	insert(10,30);
	insert(40,40);
	
	printf("\n第二次扫描输出:\n");
	outputlink();
	delectlink(30);
	delectlink(50);
	
	printf("\n第三次扫描输出:\n");
	outputlink();
	
	return 0;
}

// 建议:写代码的时候,请注意代码的可读性。 
hugett 2013-05-26
  • 打赏
  • 举报
回复
你的函数声明没有返回类型。。
AVE缌念 2013-05-26
  • 打赏
  • 举报
回复

69,373

社区成员

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

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