Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ios::nocreate

183 views
Skip to first unread message

Joshua Emele

unread,
May 11, 2001, 8:25:21 PM5/11/01
to
Hi -
Im using msvc++ 6; it seems ios::nocreate is not defined.
Looking in <xiobase> is see:
enum _Openmode
{ // constants for file opening options
in = 0x01, out = 0x02, ate = 0x04,
app = 0x08, trunc = 0x10, binary = 0x20};

so where's that darned nocreate?

TIA,
joshua


Igor Tandetnik

unread,
May 14, 2001, 11:35:09 AM5/14/01
to
nocreate is defined in the old style iostreams (you know, where headers have
.h extension, like <fstream.h> instead of <fstream>). For new style
iostreams, if you specify ios_base::in flag and do not specify
ios_base::trunc flag when opening files, the operation fails if the file
does not exist. If you need write access, specify in | out flags.

This behavior is guaranteed by C++ standard

27.8.1.3 Member functions

2 ... It then opens a file, if possible, whose name is the NTBS s ("as if"
by calling std::fopen(s, modstr)).
The NTBS modstr is determined from mode & ~ios_base::ate as indicated in
Table 92...

and Table 92 maps in to "r", in | out to "r+", in | binary to "rb" and in |
out | binary to "r+b".

Now C standard says:

7.19.5.3 The fopen function

4 Opening a file with read mode ('r' as the first character in the mode
argument) fails if the file does not exist or cannot be read.

--
With best wishes,
Igor Tandetnik


"Joshua Emele" <jem...@colevalley.com> wrote in message
news:e6Ixeon2AHA.2000@tkmsftngp05...

Linke, Ralf

unread,
May 18, 2001, 8:15:10 AM5/18/01
to
> -----Ursprüngliche Nachricht-----
> Von: Joshua Emele [mailto:jem...@colevalley.com]
> Bereitgestellt: Samstag, 12. Mai 2001 02:25
> Bereitgestellt in: stl
> Unterhaltung: :nocreate
> Betreff: ios::nocreate
>
>
Hi Joshua

> Im using msvc++ 6; it seems ios::nocreate is not defined.
> Looking in <xiobase> is see:

> [definition of _Openmode]


> so where's that darned nocreate?

Calm down, and open your eyes (SCNR ;-) ):
you're looking for ios::<something>, so just look in the right header:
in ios.h, you find

class ... ios {
enum open_mode{...}, with nocreate neatly defined!
}

regards,
Ralf Linke

Robin

unread,
May 20, 2001, 10:29:56 PM5/20/01
to
"Linke, Ralf" <Lin...@eplan.de> wrote:
>Calm down, and open your eyes (SCNR ;-) ):
>you're looking for ios::<something>, so just look in the right header:
>in ios.h, you find
>
>class ... ios {
>enum open_mode{...}, with nocreate neatly defined!
>}

He's looking for the new std ios, not the deprecated ios.h

Joshua Emele

unread,
May 25, 2001, 7:40:16 PM5/25/01
to
thanks a ton. and yeah, im not touching the deprecated .h files.

"Robin" <darka...@yahoo.com> wrote in message
news:9e9un...@enews1.newsguy.com...

0 new messages