#include<iostream>
#include<string>
using namespace std;
struct one
{
char name_book[80];
char name_author[80];
int no_of_books;
}one1[500];
int insert()
{
int i,j;
cout<<"Enter the No. of Books you want to enter : ";
cin>>i;
cout<<endl;
for(j=0;j<i;j++)
{
cout<<"Enter the name of book "<<j+1<<" : ";
cin>>one1[j].name_book;
cout<<"Enter the name of the Author of the book "<<j+1<<" : ";
cin>>one1[j].name_author;
cout<<"Enter the number of books in this title "<<" : ";
cin>>one1[j].no_of_books;
cout<<"\n";
}
for(j=0;j<i;j++)
{
cout<<"The name of book "<<j+1<<" is : ";
cout<<one1[j].name_book;
cout<<endl;
cout<<"The author's name for book "<<j+1<<" is : ";
cout<<one1[j].name_author;
cout<<endl;
cout<<"The number of books in this title are "<<"book is : ";
cout<<one1[j].no_of_books;
cout<<endl;
}
return 0;
}
void main()
{
insert();
}
The problem is in line 20 i have to use cin and am not able to use cin.getline
but cin.getline should be used as cin breaks when it reads a space that's why cin.getline should be used but when i use cin.getline the entry for teh 1st book is not taken but it runs normally for the entry of second book plz help!!