Thread: equivalent to is_open() ?

  1. #1
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431

    equivalent to is_open() ?

    Is there any standard way to check to see if a file is open? I have looked through stdio.h, but it doesn't look like it has anything. What happens to a FILE after it is closed with fclose() ?
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Any buffers are flushed and the file is closed. The pointer still dangles, though, if that's what you're asking. If you're opening and closing file handles, you can set the pointer to NULL when you close a file, and check for that before reopening.

  3. #3
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Thanks tabstop. That answered my question perfectly.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. string equivalent of sprintf()
    By e66n06 in forum C++ Programming
    Replies: 4
    Last Post: 08-16-2007, 03:30 PM
  2. Pointer equivalent to array notation
    By bekkilyn in forum C Programming
    Replies: 4
    Last Post: 12-06-2006, 08:22 PM
  3. Replies: 10
    Last Post: 08-17-2005, 11:17 PM
  4. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  5. UNIX fork() equivalent in Windows
    By argon in forum Windows Programming
    Replies: 2
    Last Post: 01-04-2002, 01:56 PM