我需要验证bookid
结构成员。此代码与库管理代码有关....我需要验证从用户获取的所有输入。应包括作者姓名,书籍详细等所有输入。
struct
{
int bid;
char bname[25] ;
char author[25];
int nooftitles;
char titles[500];
int status;
}book;
void Addbook()
{
int i;book.status=IN;
//opening the librecord file
librecord = fopen("librecord.txt","a+");
//need to validate below member
printf("Enter The uniqueid of The Book :(Integer) \n");
scanf("%d",&book.bid);
printf("Enter The Name of The Book :\n");
scanf("%s",book.bname);
printf("Enter The Name of Author :\n");
scanf("%s",book.author);
printf("Enter The Number of Titles Of The Book:(Integer)\n");
scanf("%d",&book.nooftitles);
fprintf(librecord,"\n%d\t%s\t%s\t%d\t%d\t",book.bid,book.bname,book.author,book.status,book.nooftitles);
printf("Enter The Titles Of The Book : \n");
for(i=0;i<book.nooftitles;i++)
{
scanf("%s",book.titles);
fprintf(librecord,"%s\t",book.titles);
}
fclose(librecord);
printf(" (' ' ) A New Book has been Added Successfully...\n");
}