Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

V3rt3x

<iostream> or <iostream.h> ???

This topic is 5732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Erm.. why is there two versions a little differents ? with < iostream > I need to call objects from the std namespace, or if I include < fstream > I can't use ios::nocreate (or I'm a newbie and I don't know how to :x). So why two files (one with extenstion) for a same header ? And then, what is the best to include for portability code ? [edited by - V3rt3x on December 4, 2002 5:33:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
iostream.h is deprecated. Compilers include it only for backwards compatibility with older code. Use the newstyle (iostream) headers, which include, among other things, support for namespaces.

Share this post


Link to post
Share on other sites
You should be particularly careful about this stuff especially with regards to iostreams

In Visual C++, v6, including iostream.h gets you the non-templatized, pre-standard version of the stream library.

always use the form unless you KNOW you need the other one for some reason

Share this post


Link to post
Share on other sites
you should use the ones without the ".h" if possible, since they are the not outdated like the ".h" ones (which are included for backward compatiblity).

as a side note, you can use "std::ios::nocreate" for the < iostream> thing...

Share this post


Link to post
Share on other sites
quote:
Original post by Miserable
iostream.h is deprecated.

It''s not even deprecated. It was never Standardised. Quite simply iostream.h is not guaranteed to be present and, if it does happen to exist, there''s no guarantees made about what''s in it.

Share this post


Link to post
Share on other sites
quote:
Original post by krez
you should use the ones without the ".h" if possible, since they are the not outdated like the ".h" ones (which are included for backward compatiblity).

as a side note, you can use "std::ios::nocreate" for the < iostream> thing...



std::ios::nocreate fails

Visual C++ 6.0 return this :

C:\...\bitmap.cpp(54) : error C2039: ''nocreate'' : is not a member of ''basic_ios< char,struct std::char_traits< char > >''
C:\...\bitmap.cpp(54) : error C2065: ''nocreate'' : undeclared identifier

I included < iostream > and < fstream >.

Share this post


Link to post
Share on other sites
quote:
Original post by V3rt3x
std::ios::nocreate fails

That''s because there''s no such thing. nocreate is a vendor-supplied extension.

Share this post


Link to post
Share on other sites
ok, but is there an other choice instead of using ios::nocreate to prevent the function creating a new file?

Share this post


Link to post
Share on other sites
quote:
Original post by V3rt3x
ok, but is there an other choice instead of using ios::nocreate to prevent the function creating a new file?


std::ifstream never creates a file if it doesn''t exist.
std::ofstream always creates a file if it doesn''t exist.

nocreate
- open an ifstream
- if it fails ... return
- otherwise ... proceed

noreplace
- open an ifstream
- if it succeeds ... return
- otherwise ... proceed

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!