Advanced Minds

  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • red color
  • green color
FireBoard
Welcome, Guest
Please Login or Register.    Lost Password?
c++ ofstream C++ ofstream, errno (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: c++ ofstream C++ ofstream, errno
#7774
defunct (Visitor)
Click here to see the profile of this user
Birthdate:
c++ ofstream C++ ofstream, errno  
Hello, Is it possible to check why a file was unable to open using the ofstream class?  In C you can check errno, is there something similar for ofstream? Thank you in advance, -d       [ Send an empty e-mail to c++ This e-mail address is being protected from spam bots, you need JavaScript enabled to view it for info ]       [ about comp.lang.c++.moderated. First time posters: do this! ]
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#7775
Jack Klein (Visitor)
Click here to see the profile of this user
Birthdate:
c++ ofstream C++ ofstream, errno  
On 14 Dec 2002 06:52:51 -0500, This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (defunct) wrote in comp.lang.c++.moderated:   Hello,     Is it possible to check why a file was unable to open using the   ofstream class?  In C you can check errno, is there something similar   for ofstream?     Thank you in advance,   -d There is no standard way, in either C or C++.  The fact that your implementation sets errno to some value that you consider useful when fopen() fails is in fact a non-portable extension.  The C standard does not require that fopen() set errno on failure. I would suggest consulting your compilers documentation to see if it provides a similar extension for C++.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#7776
John Torjo (Visitor)
Click here to see the profile of this user
Birthdate:
c++ ofstream C++ ofstream, errno  
Hello, Is it possible to check why a file was unable to open using the ofstream class?  In C you can check errno, is there something similar for ofstream? You can check the stream's state. If the file could not be open (or read from), one of the flags would be set. You can simply ask: if ( stream.fail())     std::cout << could not open/ read file ; or more specific, ask for the std::ios__base_::failbit flag, like this: if ( stream.rdstate() & std::ios__base_::failbit)     std::cout << could not open/ read file ; Hope this helps. Check your documentation: there's a lot more to know about the state of a stream. I would recommend the C++ Language 3rd ed, where there's a whole chapter on streams. Best, John
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
nieautoryzowano 905 sprawdz autoryzacje sprawdz autoryzacje wymiana linkow
dive play runescape2 ssi diving 2008 tax rebates adventure travel