Code:struct AddressBook{
string Name;
string Email;
string Address;
string Town;
string Postcode;
string Phone;
};
void ReadBook(ifstream &fin, AddressBook &book,int total){
for(int x = 0;x<total;x++){
string strVal ="";
strVal = "<" + x;
strVal += ">";
string strTemp = "";
while(getline(fin,strTemp, '*')){
if(strTemp == strVal)
{
fin>>strTemp>>book[x].Name;
fin>>strTemp>>book[x].Email;
fin>>strTemp>>book[x].Address;
fin>>strTemp>>book[x].Town;
fin>>strTemp>>book[x].Postcode;
fin>>strTemp>>book[x].Phone;
}
};
}
}
int main(){
ifstream fin(ADDRESS_LOCATION);
int Record_ID = GetRecords(fin);
AddressBook *book;
book = new AddressBook[Record_ID];
ReadBook(fin,*book[Record_ID],Record_ID);
delete book;
return 0;
}
any ideas what im doing wrong.Quote:
c:\C++\Addressbook\source1.cpp(43): error C2676: binary '[' : 'AddressBook' does not define this operator or a conversion to a type acceptable to the predefined operator
c:\C++\Addressbook\source1.cpp(43): error C2228: left of '.Name' must have class/struct/union type
... and the same for all the items in the struct
Thanks :)
