I'm facing some issue which I can't identify.
I have a structure 'album'. I try to read two albums from standard input. The first one works perfectly fine, but on the second one, it appears like this:
(..after first album has been read:)somehow, I can't enter a title, since 'band:' is already there..
title:
>band:
>
I use this function to read an album:
Expand|Select|Wrap|Line Numbers
- void read_alb(struct album *alb) {
- char buffer[MAX];
- printf("title:\n>");
- fgets(buffer, MAX, stdin);
- trim(buffer); /* removes newline */
- strcpy((*alb).title, buffer);
- printf("band:\n>");
- fgets(buffer, MAX, stdin);
- trim(buffer);
- strcpy((*alb).band, buffer);
- printf("year:\n>");
- scanf("%d", &(*alb).year);
- }
I'd be grateful if somebody could give me some advice.
Regards,
rethab