hard disk full while writing to file
-
I'm writing some data to a CStdioFile in a loop, and my program gets through the loop but gives me an error when I close the dialog, saying "hard disk full while writing to file". The file is blank. I know the hard disk is not ACTUALLY full, so is this caused by a memory leak somewhere in my code? A possible cause would be a loop where I read from a file: CPerson *p; while (...) { CString name = (read a name from a file) p = new Person(name); //should this next line do the job? delete (p); } I'm not a memory freeing guru, so I'm definitely causing some trouble here :laugh: How can I get this file written? thanks, Jake
-
I'm writing some data to a CStdioFile in a loop, and my program gets through the loop but gives me an error when I close the dialog, saying "hard disk full while writing to file". The file is blank. I know the hard disk is not ACTUALLY full, so is this caused by a memory leak somewhere in my code? A possible cause would be a loop where I read from a file: CPerson *p; while (...) { CString name = (read a name from a file) p = new Person(name); //should this next line do the job? delete (p); } I'm not a memory freeing guru, so I'm definitely causing some trouble here :laugh: How can I get this file written? thanks, Jake
The delete line is definately what you need to free the memory before calling new again, otherwise you'll leak memory for sure. As an aside, it probably dosn't matter directly in this case, but it is *always* a good idea to set pointers you've called delete on to NULL. Jonathon