So basically, I have an array of structs which I have dynamically allocated.
  using namespace std;
  struct library
  {
    string bookname;
    string author;
    int bookno;
  };
  int main()
  {
           library *lib=NULL;
           lib=malloc(sizeof(lib)*1);
           lib=(library*)realloc(lib,2);
           cout<<"Enter Book Name: "<<endl;
           getline(cin,lib[i]->bookname);
 }
In the above program I'm creating a array of structure for a library. I have reallocated from 1 space to 2 spaces which can be increased to more. But I'm having problem in getting input to member variable of each array member. The lib[i] is causing error here.
 
     
     
    