too many types in declaration

huaxiangsl 2008-05-17 07:44:54
too many types in declaration???

什么意思啊。。。
...全文
373 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
arong1234 2008-05-18
  • 打赏
  • 举报
回复


struct library
{ char indexnum[9]; /* 索引号*/
char title[20]; /* 书名*/
char autor[20];/* 作者*/
char published[20];/* 出版社*/
char classify;/* 图书类别 用一个字母表示*/
char state[4];/* 是否借出 in , out */
struct library *next;
} // <----这里需要一个分号

chlaws 2008-05-18
  • 打赏
  • 举报
回复
看下where中和if中strcmp(p->indexnum,p->indexnum)>0
这句哪能这样,这是自己和自己比较啊.肯定没戏的
laden45 2008-05-18
  • 打赏
  • 举报
回复
struct *AddList(struct library *head)
struct *Insert(struct library *head,struct library *p0)
这2个函数的返回值都不对
struct是什么?
应该改成
struct library *AddList(struct library *head)
struct library *AddList(struct library *head)

最好在定义 struct library
{ char indexnum[9]; /* 索引号*/
char title[20]; /* 书名*/
char autor[20];/* 作者*/
char published[20];/* 出版社*/
char classify;/* 图书类别 用一个字母表示*/
char state[4];/* 是否借出 in , out */
struct library *next;
} ;的后面加上
typedef struct library AA;
以后就可以写成
AA *AddList(struct library *head)
AA *AddList(struct library *head)
其他地方的typedef struct都可以改成AA了.


huaxiangsl 2008-05-17
  • 打赏
  • 举报
回复
#define LEN sizeof(struct library)
struct library
{ char indexnum[9]; /* 索引号*/
char title[20]; /* 书名*/
char autor[20];/* 作者*/
char published[20];/* 出版社*/
char classify;/* 图书类别 用一个字母表示*/
char state[4];/* 是否借出 in , out */
struct library *next;
}
struct *AddList(struct library *head) /* 创建链表,追加图书记录 */
{ struct library *p;
while(1)
{ p=(struct library*)malloc(LEN);
printf("please input the data...and indexnum==## is exit\n");
printf("indexnum=\n");
scanf("%s",p->indexnum);
if (p->indexnum=="##")
{ free(P); break;}
printf("title=\n");
scanf("%s",p->title);
printf("autor=\n");
scanf("%s",p->autor);
printf("published=\n");
scanf("%s",p->published);
printf("classify=\n");
scanf("%c",&p->classity);
p->state="in";
head=Insert(head,p);
}
return head;
}
struct *Insert(struct library *head,struct library *p0) /* 插入,,并按索引号大小排序 */
{ struct library *p,*q;
p=q=head;
if (head==0)
{ head=p0;p->next=0 }
else
while(strcmp(p->indexnum,p->indexnum)>0&&(p->next!=0))
{ q=p;p=p->next;}
if (strcmp(p->indexnum,p->indexnum)>0)
{ if (p==head) { head=p0; p->next=p; }
else { q->next=p0; p->next=p; }
}
else { p->next=p0; p->next=0 }
return head;
}
arong1234 2008-05-17
  • 打赏
  • 举报
回复
出错行代码(包括前后5行)都贴一下
chlaws 2008-05-17
  • 打赏
  • 举报
回复
汗.声明太多类型.
看下将长语句分为多行时,与下一行语句间
是否少了逻辑运算符关系,关系运算符之类的符号
iu_81 2008-05-17
  • 打赏
  • 举报
回复
Too many types in the declaration
意思是:定义太多的类型
iu_81 2008-05-17
  • 打赏
  • 举报
回复
是否多次包含着个头文件?检查一下例如:
#ifndef TConfigH
#define TConfigH

#endif //是否少了这个

69,382

社区成员

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

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