Dovrebbe essere così..
void banca::saveOnFile(){
FILE *myFile;
Persona temp;
Persona* index = lista; //punta al primo elemento della lista
cout<<"\n\n "<<n<<"\n\n ";
myFile = fopen("banca.bin", "w+b");
while(index!=0){
temp = *index;
cout<<"\n*** "<<temp->getNome()<<" - SCRITTO ***";
fwrite(&temp, sizeof(Persona),1,myFile);
fflush(myFile);
index=index->getNext();
}
fclose(myFile);
cout<<"\n***********************************************";
myFile = fopen("banca.bin", "r+b");
while(!feof(myFile)){
fread(&tempo, sizeof(Persona),1,myFile);
cout<<"\n*** "<<tempo->getNome()<<" *** - LETTO";
cout<<"\n*** "<<tempo->getCognome()<<" ***";
cout<<"\n*** "<<tempo->getCodFisc()<<" ***";
cout<<"\n*** "<<tempo->getUserId()<<" ***";
cout<<"\n*** "<<tempo->getPwd()<<" ***";
}
fclose(myFile);
getchar();
system("cls");
}
|