odd I/O compile error

This is a discussion on odd I/O compile error within the C++ Programming forums, part of the General Programming Boards category; The compiler says the opposite......

  1. #16
    Registered User
    Join Date
    May 2004
    Posts
    20
    The compiler says the opposite...

  2. #17
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >It is perfectly fine.
    How is that? The open member function for ifstream returns void, so you can't use the return value as a test for success. One would need to call the is_open member function to check the status.
    Code:
    ifstream winfilein("wins.txt"); // ios_base::in is defaulted
    
    if (winfilein.is_open()) {
      winfilein.close();
      // blahblah
    }
    My best code is written with the delete key.

  3. #18
    Registered User
    Join Date
    May 2004
    Posts
    20
    doh... it returns void?
    that would help, thx

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 10:15 PM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02:17 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

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