Grekalov
21-12-2005, 16:58
Доброго времени суток! Решил заняться изучением программирования и начал с книги М.Уэйт, С.Прата, Д.Мартин "Язык Си" Москва "МИР" 1988 г. Ошибок в листинге программ достаточно, но удавалось исправить их самому (до вчерашнего вечера). В нижеприведенном примере текста программы не могу понять, почему не отрабатывает до конца программа, доходит до ввода цены и все. Подскажите начинающему???
Вот сам листинг:
# include <stdio.h>
# define MAXTIT 40
# define MAXAUT 40
# define MAXBOX 100
# define STOP " "
struct book
{
char title [MAXTIT];
char autor [MAXAUT];
float value;
};
main()
{
struct book libry [MAXBOX];
int count=0;
int index;
printf("Vvedite nazvanie knigi\n");
printf("Najmite klavishu [ENTER] v nachale stroki dlya ostanova\n");
while (strcmp(gets(libry [count].title), STOP)!=0 && count<MAXBOX)
{
printf("Vvedite teper familiyu avtora\n");
gets(libry [count].autor);
printf ("Vvedite teper cenu\n");
scanf("%f", &libry [count++].value);
while (getchar()!='n');
if (count<MAXBOX)
printf ("Vvedite nazvanie sleduyushey knigi\n");
}
printf ("Vot spisok knig:\n");
for (index=0; index<count;index++)
printf ("%s, $s: %2.2\n", libry [index].title,
libry [index].autor, libry [index].value);
}
Вот сам листинг:
# include <stdio.h>
# define MAXTIT 40
# define MAXAUT 40
# define MAXBOX 100
# define STOP " "
struct book
{
char title [MAXTIT];
char autor [MAXAUT];
float value;
};
main()
{
struct book libry [MAXBOX];
int count=0;
int index;
printf("Vvedite nazvanie knigi\n");
printf("Najmite klavishu [ENTER] v nachale stroki dlya ostanova\n");
while (strcmp(gets(libry [count].title), STOP)!=0 && count<MAXBOX)
{
printf("Vvedite teper familiyu avtora\n");
gets(libry [count].autor);
printf ("Vvedite teper cenu\n");
scanf("%f", &libry [count++].value);
while (getchar()!='n');
if (count<MAXBOX)
printf ("Vvedite nazvanie sleduyushey knigi\n");
}
printf ("Vot spisok knig:\n");
for (index=0; index<count;index++)
printf ("%s, $s: %2.2\n", libry [index].title,
libry [index].autor, libry [index].value);
}