Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem when closing a file...

Status
Not open for further replies.

foxjoker

Programmer
Jul 5, 2000
22
US
Hi !

I develop an application that can read data from a file and go back in this file, using fsetpos function.
At end of use, I try to close the file, using fclose.
But sometimes it generates an error and crashes my application !
I can't explain this, why can't I sometimes close this file ?

Thanks

foxjoker
 
For starters, check these two things:

1) Make sure input and output string buffers are large enough for anything they may have to handle.

2) Make sure you always check that the file pointer is not NULL before trying to use it or close it.

if (fp != NULL)
{
close(fp);
}
 
OK, I don't have any problem of this kind, because I'm sure there's a handle to this file. But if I use fseek or fsetpos with it, it can't be closed normally. It is not a problem of parameters of these functions, I already checked this .Is there any madatory condition to use fseek or fsetpos with a file ?

Thank you !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top