I am currently making a code for a project (using WinApi), in which I must save data such as contact information and apointments in a binary file. Everything works except the saving part. In the code below while running it doesn't evaluate the if statement --if (myFile.is_open()) {}-- it just "skips" it, asi if it were not even there.
** "myFile" being a fstream type variable.
void guardareg(Registros *inicio)
{
myFile.open("myList.bin", ios::out | ios::trunc |
ios::binary);
if (myFile.is_open()) {
Registros *temp = inicio;
while (temp != NULL)
{
myFile.write(reinterpret_cast<char *>(temp),
sizeof(Registros));
temp = temp->sig;
}
myFile.close();
}
return;
}
Aucun commentaire:
Enregistrer un commentaire