   problem closing a file
  ok, I''ll try to explain my problem as clearly as I can...I have 2 functions that I use in my main(): void init(FILE *fp){fopen(......) ;  // I open the file and write something to it}void exit(FILE *fp){fclose(fp)  // here I try to close the file that I passed to my function}now I have thisvoid main(){FILE *file ;init(file) ;exit(file) ;}it is very simple explained I hope...Now when I run my program everything runs fine, he writes to the file with no problembut then when I try to exit my program I get an error from windows XP (right at the point of fclose(fp))so I guess it''s because the pointer is wrong???some1 that can help me out here?thanx in advance 
  I'm guessing you've got a naming problem. The C run time defines the function:void exit(int code);   which is used to terminate a program. By defining your own 'exit' function, the linker will refer to your own version of 'exit' instead of the one in the run time library (the linker doesn't know about argument types so can't tell the difference between an 'exit (int)' and an 'exit (FILE *)'). So, when your 'main' function has completed, the run time library (the code that called the 'main' function) calls 'exit' to terminate the program; only in your case, it's calling your exit function. So, you will be getting a bad value for 'fp' parameter.If you want to verify this, add a 'printf' to the start of your exit function and it should appear twice.Change the name of your 'exit' function to something like 'my_exit' and the problem will be sorted.Skizz [edited by - Skizz on February 9, 2004 2:41:39 PM];  Change your init function to take the pointer as a reference to a pointer (or as a pointer to a pointer). The way you are doing it you are only changing the local variable fp.void init(FILE** fp){   *fp = fopen(...);}orvoid init(FILE*& fp){   fp = fopen(...);} [How To Ask Questions|STL Programmer''s Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN] ;  => skizz : sorry that wasn''t my problem, because in my example I said my function was exit() but I translated it to english, in my program my function is afsluiten() (dutch) :Dbut thanx anyway for trying=> dalleboy : that seems to work, I don''t get that error anymore, so big thank you to you ;  You should try and close a file as soon as possible. Open the file, read the data into memory then close the file all in one function. The way you are doing it is just asking for trouble.