一段小程序,有点问题,不知道怎么解决,大家都来看看
程序代码:#include<stdio.h>
#define TITL 40
#define AUTL 40
#define BKS 2
struct book {
char title[TITL];
char author[AUTL];
float value;
};
int main()
{
struct book library[BKS];
int count = 0;
int index;
printf("Please enter the book title.\n");
printf("Press [enter] at the start of a line to stop.\n");
while(count < BKS && gets(library[BKS].title) != NULL && library[count].title[0] != '\0')
{
printf("Now enter the author.\n");
gets(library[count].author);
printf("Now enter the value.\n");
scanf("%f",&library[count++].value);
while(getchar() != '\n');
if(count < BKS)
printf("Enter the next title.\n");
}
if(count > 0)
{
printf("Here is the list of your books: \n");
for(index = 0; index < count; index++)
printf("%s by %s:$%.2f\n", library[index].title, library[index].author, library[index].value);
}
else
printf("No books?Too bad.\n");
return 0;
}









