Home > Back-end >  C file operations of the write and read is what stuck in blocking mode? For help
C file operations of the write and read is what stuck in blocking mode? For help

Time:09-16

Below is a c + + file save operation, the purpose is to save the Teacher objects (metadata with linked lists to store) to a file, I tested the function of the save and read can be successful, but after in the preservation and read out after (that is, to perform the write and read) program will enter the blocking mode stuck, unable to continue, that is why, is there any bosses have solution
 
//write file
Bool writeFile (TL) TL * {
If (isNull (tl - & gt; Next) | | tl - & gt; Next - & gt; The teacher. GetNumber ()==0) {
Cout & lt; <"NULL" & lt; return false;
}
TL * node=TL;
Fstream outfile (" d: \ \ try. TXT ", the ios: : out | ios: : binary);
if (! Outfile) {
Cerr & lt; <"The open file error!" ;
}
While (node - & gt; Next)
{
The Teacher the Teacher=node - & gt; Next - & gt; The teacher;
Outfile. Write ((char *) & amp; The teacher, sizeof (the teacher));//write data

The node=node - & gt; next;
}
Outfile. Close ();
return true;
}
  • Related