I have the following code:
`#include<iostream>
using namespace std;
struct book
{
int id;
char name[50];
int price;
};
int main()
{
book b1;
book input();
b1=input();
void display(book );
display( b1);
return 0;
}
book input()
{
book b;
cout<<"Enter the following details:";
cout<<"Book Id: ";
cin>>b.id;
cout<<"Book Name: ";
cin.getline(b.name, 50);
cout<<"Price: ";
cin>>b.price;
return (b);
}
void display(book b)
{
cout<<"Name: "<<b.name<<endl;
cout<<"ID: "<<b.id<<endl;
cout<<"Price: "<<b.price;
}
`
This program doesnot produce any error on compilation. However when run, it takes input for book id but skips the name part and again takes input for price. I couldn't figure out why is that happening.