| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 548 人关注过本帖
标题:一个用链表做的查询的程序出的这个所谓的错误我真不知道错在哪里
只看楼主 加入收藏
有人走
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-5-14
收藏
 问题点数:0 回复次数:3 
一个用链表做的查询的程序出的这个所谓的错误我真不知道错在哪里

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct listNode
{int num;
char name[20];
char sex;
int age;
int score[5];
struct listNode *next;
};
struct listNode *head, *tail;
void put_to_end(struct listNode *p)
{p->next=NULL;
if(head==NULL) head=p;
else tail->next=p;
tail=p;
}
void input_data()
{
int i;
char ch;
struct listNode *p;
while(1)
{
printf("\nInput data(Y/N):");
scanf("\n%c",&ch);
if(ch=='y'||ch=='Y')
{
p=malloc(sizeof(struct listNode));
printf("Input num:");
scanf("%d",&p->num);
printf("Input name:");
scanf("%s",&p->name);
printf("Input sex:");
scanf("%c",&p->sex);
printf("Input age:");
scanf("%d",&p->age);
printf("input 5 score:");
for(i=0;i<5;i++)
scanf("%d",&p->score[i]);
put_to_end(p);
}
else break;
}
}
void FDname()
{ int i;
char name[20];
struct listNode *p;
printf("Input name:");
scanf("%s",name);
p=head;
while(p!=NULL)
{if(strcmp(name,p->name)==0)
{printf("Num=%d\n",p->num);
printf("Name=%s\n",p->name);
printf("Sex=%c\n",p->sex);
printf("Age=%d\n",p->age);
for(i=0;i<5;i++)
printf("score[%d]=%d\n",i+1,p->score[i]);
}
p=p->next;
}
}
void FDnum()
{int i,snum;
struct listNode *p;
printf("Input num:");
scanf("&d",&snum);
p=head;
while(p!=NULL)
{ if(snum==p->num)
{ printf("Num=%d\n",p->num);
printf("Name=%s\n",p->name);
printf("Sex=%c\n",p->sex);
printf("Age=%d\n",p->age);
for(i=0;i<5;i++)
printf("score[%d]=%d\n",i+1,p->score[i]);
}
p=p->next;
}
}

void find_data()
{char ch;
while(1)
{
printf("\n1:Find by name\n");
printf("2:Find by num\n");
printf("3:Exit\n");
scanf("\n%c",&ch);
switch(ch)
{case '1': FDname();
break;
case '2': FDnum();
break;
case '3': return;
}
}
}

main()
{ head=NULL,tail=NULL;
input_data();
find_data();
}



编译後提示错误是这个
但是我都定义了的啊

--------------------Configuration: Text1 - Win32 Debug--------------------
Compiling...
Text1.c
c:\documents and settings\qqq\桌面\text1.c(26) : error C2018: unknown character '0xa3'
c:\documents and settings\qqq\桌面\text1.c(26) : error C2018: unknown character '0xbb'
c:\documents and settings\qqq\桌面\text1.c(27) : error C2146: syntax error : missing ';' before identifier 'scanf'
执行 cl.exe 时出错.


很着急啊

搜索更多相关主题的帖子: 链表 struct listNode tail 
2007-05-15 13:36
无语的我
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-4-25
收藏
得分:0 

printf("\nInput data(Y/N):");
你的分号是中文里的.改成;就OK了.


2007-05-15 14:27
ibiancheng
Rank: 1
等 级:新手上路
帖 子:148
专家分:0
注 册:2007-4-3
收藏
得分:0 
if(ch=='y'||ch=='Y') {
p=malloc(sizeof(struct listNode));
printf("Input num:");
scanf("%d",&p->num);
printf("Input name:");
scanf("%s",&p->name);
printf("Input sex:");
scanf("%c",&p->sex);
printf("Input age:");
scanf("%d",&p->age);
printf("input 5 score:");
for(i=0;i<5;i++)
scanf("%d",&p->score[i]);
put_to_end(p);
}
else break;
怎么我看的书上说break不能用到if,else语句中的??

执著的信念,坚定的自信,勤奋的努力才是通向成功的捷径! !!
2007-05-15 14:57
无语的我
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-4-25
收藏
得分:0 

不知道你看的是什么书.
那个break是跳出while(1)循环


2007-05-15 17:19
快速回复:一个用链表做的查询的程序出的这个所谓的错误我真不知道错在哪里
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014118 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved