Listing 7 Illustrates a dangling resource

// destroy3.cpp
#include <stdio.h>

void f(char *fname);

main()
{
   try
   {
      f("file1.dat");
   }
   catch(...)
   {}
   return 0;
}

void f(char *fname)
{
   FILE *fp = fopen(fname,"r");
   if (fp)
   {
      // Use f, then throw an
      // exception
      throw 1;
      fclose(fp);     // This won't
                   // happen
   }
}

// End of File