I know its probably a stupid question but I’m learning and I need help. Can someone explain to me why does my program stops getting input from the console after the first book.
#include <stdio.h>
#include <stdlib.h>
typedef struct book
{
char title[50];
char author[50];
int year;
int price;
}Book;
Book getInfo()
{
Book b1;
scanf("%[^\n]%*c",b1.title);
scanf("%[^\n]%*c",b1.author);
scanf("%d",&b1.year);
scanf("%d",&b1.price);
return b1;
}
int main()
{
Book books[2];
for(int i=0;i<2;i++)
{
books[i]=getInfo();
}
printf("%s-%s-%d-%d",books[0].title,books[0].author,books[0].year,books[0].price);
return 0;
}