#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct book{
char book_name[30];
int bianhao;
double price;
char author[20];
char state[20];
char name[20];
char sex[10];
int xuehao;
struct book *book_next;
};
struct club{
char name[20];
char sex[10];
int xuehao;
char borrow[30];
struct club *club_next;
};
void Print_Book(struct book *head_book);/*浏览所有图书信息*/
void Print_Club(struct club *head_club);/*浏览所有会员信息*/
struct book *Create_New_Book();/*创建新的图书库,图书编号输入为0时结束*/
struct book *Search_Book_bianhao(int bianhao,struct book *head_book);
struct book *Search_Book_name(char *b_name,struct book *head_book);
struct book *Search_Book_price(double price_h,double price_l,struct book *head_book);
struct book *Insert_Book(struct book *head_book,struct book *stud_book);/*增加图书,逐个添加*/
struct book *Delete_Book(struct book *head_book,int bianhao);/*删除图书*/
struct club *Create_New_Club();
struct club *Search_Club_xuehao(int xuehao,struct club *head_club);
struct club *Search_Club_name(char *c_name,struct club *head_club);
struct club *Insert_Club(struct club *head_club,struct club *stud_club);
struct club *Delete_Club(struct club *head_club,int xuehao);
struct book *Lent_Book(int bianhao,int xuehao,struct book *head_book,struct club *head_club);
struct book *back(int bianhao,int xuehao,struct book *head_book,struct club *head_club);
int main()
{
struct book *head_book,*p_book;
char book_name[30],name[20],author[20],sex[10];
int bianhao;
double price,price_h,price_l;
int size_book=sizeof(struct book);
int m=1,n=1,f;
char *b_name,*c_name;
struct club *head_club,*p_club;
int xuehao;
int size_club=sizeof(struct club);
break;
case 8:
system("cls");
printf("/n/t/t/t〓〓〓〓〓图书管理系统〓〓〓〓〓/n/n");
printf("请输入会员名字:");
scanf("%s",name);
printf("请输入会员性别:");
scanf("%s",sex);
printf("请输入会员学号:");
scanf("%d",&xuehao);
printf("/n");
struct club *ptr_c;
for(ptr_c=head_club;ptr_c;ptr_c=ptr_c->club_next)
{
if(ptr_c->xuehao==xuehao)
{
printf("此学号会员已存在/n");
n=0;
break;
}
}
if(n){
p_club=(struct club *)malloc(sizeof(struct club));
strcpy(p_club->name,name);
strcpy(p_club->sex,sex);
p_club->xuehao=xuehao;
strcpy(p_club->borrow,"暂无");
head_club=Insert_Club(head_club,p_club);
printf("/n添加会员成功!/n/n");
}
break;
case 9:
system("cls");
printf("/n/t/t/t〓〓〓〓〓图书管理系统〓〓〓〓〓/n/n");
printf("输入要删除会员学号:/n");
scanf("%d",&xuehao);
head_club=Delete_Club(head_club,xuehao);
printf("/n删除会员成功!/n/n");
break;
case 10:
system("cls");
printf("/n/t/t/t〓〓〓〓〓图书管理系统〓〓〓〓〓/n/n");
Print_Club(head_club);
break;
case 0:
system("cls");
printf("/n/t/t/t〓〓〓〓〓图书管理系统〓〓〓〓〓/n/n");
printf("/n谢谢您的使用!/n/n");
break;
}
}while(choice!=0);
return 0;
}
struct book *Create_New_Book()
{
struct book *head_book,*p_book;
int bianhao;
double price;
char book_name[30],author[20];
int size_book=sizeof(struct book);
return head_book;
}
struct club *Create_New_Club()
{
struct club *head_club,*p_club;
int xuehao;
char name[20],sex[10];
int size_club=sizeof(struct club);
return head_book;
}
struct book *back(int bianhao,int xuehao,struct book *head_book,struct club *head_club)
{
struct book *ptr_book;
struct club *ptr_club;
int flag=0;
return head_club;
}
void Print_Book(struct book *head_book)
{
struct book *ptr_b;
if(head_book==NULL){
printf("/n无记录/n/n");
return;
}
printf("/n图书编号/t图书名称/t图书单价/t图书作者/n/n");
for(ptr_b=head_book;ptr_b;ptr_b=ptr_b->book_next)
printf("%d/t/t%s/t/t%.2lf/t/t%s/n/n",ptr_b->bianhao,ptr_b->book_name,ptr_b->price,ptr_b->author);
}
这段代码编译之后 就报错 报这个
--------------------Configuration: 14 - Win32 Debug--------------------
Compiling...
14.c
F:\C\14.c(149) : error C2143: syntax error : missing ';' before 'type'
F:\C\14.c(150) : error C2065: 'ptr_b' : undeclared identifier
F:\C\14.c(150) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct book *'
F:\C\14.c(150) : error C2223: left of '->book_next' must point to struct/union
F:\C\14.c(152) : error C2223: left of '->bianhao' must point to struct/union
F:\C\14.c(229) : error C2143: syntax error : missing ';' before 'type'
F:\C\14.c(230) : error C2065: 'ptr_c' : undeclared identifier
F:\C\14.c(230) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct club *'
F:\C\14.c(230) : error C2223: left of '->club_next' must point to struct/union
F:\C\14.c(232) : error C2223: left of '->xuehao' must point to struct/union
执行 cl.exe 时出错.
WIN32有可能不行,按照版主的说法,改了一下:[mw_shl_code=c,true]#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct book{
char book_name[30];
int bianhao;
double price;
char author[20];
char state[20];
char name[20];
char sex[10];
int xuehao;
struct book *book_next;
};
struct club{
char name[20];
char sex[10];
int xuehao;
char borrow[30];
struct club *club_next;
};
void Print_Book(struct book *head_book);/*浏览所有图书信息*/
void Print_Club(struct club *head_club);/*浏览所有会员信息*/
struct book *Create_New_Book();/*创建新的图书库,图书编号输入为0时结束*/
struct book *Search_Book_bianhao(int bianhao,struct book *head_book);
struct book *Search_Book_name(char *b_name,struct book *head_book);
struct book *Search_Book_price(double price_h,double price_l,struct book *head_book);
struct book *Insert_Book(struct book *head_book,struct book *stud_book);/*增加图书,逐个添加*/
struct book *Delete_Book(struct book *head_book,int bianhao);/*删除图书*/
struct club *Create_New_Club();
struct club *Search_Club_xuehao(int xuehao,struct club *head_club);
struct club *Search_Club_name(char *c_name,struct club *head_club);
struct club *Insert_Club(struct club *head_club,struct club *stud_club);
struct club *Delete_Club(struct club *head_club,int xuehao);
struct book *Lent_Book(int bianhao,int xuehao,struct book *head_book,struct club *head_club);
struct book *back(int bianhao,int xuehao,struct book *head_book,struct club *head_club);
int main()
{
struct book *head_book,*p_book;
char book_name[30],name[20],author[20],sex[10];
int bianhao;
double price,price_h,price_l;
int size_book=sizeof(struct book);
int m=1,n=1,f;
char *b_name,*c_name;
struct club *head_club,*p_club;
int xuehao;
int size_club=sizeof(struct club);
break;
case 8:
system("cls");
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
printf("请输入会员名字:");
scanf("%s",name);
printf("请输入会员性别:");
scanf("%s",sex);
printf("请输入会员学号:");
scanf("%d",&xuehao);
printf("\n");
struct club *ptr_c;
for(ptr_c=head_club;ptr_c;ptr_c=ptr_c->club_next)
{
if(ptr_c->xuehao==xuehao)
{
printf("此学号会员已存在\n");
n=0;
break;
}
}
if(n){
p_club=(struct club *)malloc(sizeof(struct club));
strcpy(p_club->name,name);
strcpy(p_club->sex,sex);
p_club->xuehao=xuehao;
strcpy(p_club->borrow,"暂无");
head_club=Insert_Club(head_club,p_club);
printf("\n添加会员成功!\n\n");
}
break;
case 9:
system("cls");
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
printf("输入要删除会员学号:\n");
scanf("%d",&xuehao);
head_club=Delete_Club(head_club,xuehao);
printf("\n删除会员成功!\n\n");
break;
case 10:
system("cls");
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
Print_Club(head_club);
break;
case 0:
system("cls");
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
printf("\n谢谢您的使用!\n\n");
break;
}
}while(choice!=0);
return 0;
}
struct book *Create_New_Book()
{
struct book *head_book,*p_book;
int bianhao;
double price;
char book_name[30],author[20];
int size_book=sizeof(struct book);
return head_book;
}
struct club *Create_New_Club()
{
struct club *head_club,*p_club;
int xuehao;
char name[20],sex[10];
int size_club=sizeof(struct club);
return head_book;
}
struct book *back(int bianhao,int xuehao,struct book *head_book,struct club *head_club)
{
struct book *ptr_book;
struct club *ptr_club;
int flag=0;