files files files

This is a discussion on files files files within the C++ Programming forums, part of the General Programming Boards category; i can like do stuff wit file using std: fstream filenamehere(dirgoeshere) but is there ne need to close a file ...

  1. #1
    Mmm. Purple.
    Join Date
    May 2002
    Posts
    154

    files files files

    i can like do stuff wit file using
    std:fstream filenamehere(dirgoeshere)
    but is there ne need to close a file opened for memory and sharing
    and how wud i if needed

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    filenamehere.close();

    It always pays to be tidy. For example, some OS's are "supposed" to delete an allocated memory that isn't deleted at the end of a program. But, would you rather take the risk or add the extra line of code.

  3. #3
    Unregistered
    Guest
    I think fstream's close() member is called anyway in the destructor, but I may be wrong.

  4. #4
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    It probably does, since I forgot to call close one time, and I still was able to open it, and if you don't close a file, windows barfs up some access denied errors.

  5. #5
    Mmm. Purple.
    Join Date
    May 2002
    Posts
    154

    ty

    thanks u guys(and gals if ne lol)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 07:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 04:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 05:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21