void Load()
{
book *newptr,*p,*q;
string id,title,author,year,price,date;
ifstream file1;
head = NULL;
file1.open("books.txt");
if (file1.fail())
{
cout << "Error opening file.\n";
exit(1);
}
while (!file1.eof())
{
newptr = new book; //
getline(file1,id);
getline(file1,title);
getline(file1,author);
getline(file1,year);
getline(file1,price);
getline(file1,date);
//copy values from the file to the newptr
newptr->id.assign (id) ;
newptr->title.assign (title) ;
newptr->author.assign(author) ;
newptr->year.assign (year) ;
newptr->price = atoi(price.c_str()) ;
newptr->date.assign (date) ;
if(head == NULL)
head = newptr;
else
{
p = head;
q = NULL;
while(p != NULL && p->id.compare(newptr->id)>0)
{
q = p;
p = p->next;
}
if(q == NULL)
{
newptr->next = head;
head = newptr;
}
else
{
newptr->next = p;
q->next = newptr;
}
}
}
file1.close();
when i compile;
[Error] D:\C-Free Standard\temp\Untitled3.cpp:369: request for member `assign' in `newptr->book::id', which is of non-aggregate type `char[12]'
[Error] D:\C-Free Standard\temp\Untitled3.cpp:372: request for member `assign' in `newptr->book::year', which is of non-aggregate type `int'
[Error] D:\C-Free Standard\temp\Untitled3.cpp:374: request for member `assign' in `newptr->book::date', which is of non-aggregate type `char[10]'
[Error] D:\C-Free Standard\temp\Untitled3.cpp:384: request for member `compare' in `p->book::id', which is of non-aggregate type `char[12]'