标题:一个用链表做的查询的程序出的这个所谓的错误我真不知道错在哪里
取消只看楼主
有人走
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-5-14
 问题点数:0 回复次数:0 
一个用链表做的查询的程序出的这个所谓的错误我真不知道错在哪里

#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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-139548-1-1.html




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

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