As per, http://www.devx.com/tips/Tip/14544
The following example imitates the ios::nocreate flag. First, it
attempts to open a file for read. If the file doesn't exist, no new
file is created. If the file exists, the program closes it and reopens
it in write mode:
fstream fs("fname", ios_base::in);// attempt open for read
if (!fs)
{
// file doesn't exist; don't create a new one
}
else //ok, file exists. close and reopen in write mode
{
fs.close();
fs.open("fname", ios_base::out); // reopen for write
}
You can just do the opposite for ios::noreplace:
fstream fs("fname", ios_base::in);// attempt open for read
if (!fs)
{
// file doesn't exist; create a new one
fs.open("fname", ios_base::out);
}
else //ok, file exists; close and reopen in write mode
{
fs.close()
fs.open("fname", ios_base::out); // reopen for write
}
On Tue, 22 Jun 2004 09:53:49 -0600, Noorez Kassam
I tried including the old iostream.h file but it still didn't work. Can you
give me a sample code for this?
Subject: Re: [Dev-C++] File handle
Date: Mon, 21 Jun 2004 20:31:06 -0400
As per,
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00003660&forum=general&id=-1
ios::nocreate is only implemented in the old C++ runtime library --
<iostream.h>, rather than <iostream>.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_differences_in_iostream_implementation.asp
(I presume this is the same situation with ios::noreplace)
Cheerio!
On Mon, 21 Jun 2004 17:05:52 -0600, Noorez Kassam
Post by Noorez KassamI am having trouble doing file handling.
when opening the file i can use all the opening techinques except
ios::nocreate and ios::noreplace.
All the other ones work fine but when i try to use those i get a compile
error.
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN Premium
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Post by Noorez Kassam-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Dev-cpp-users mailing list
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
Jesse Hallam
University of Waterloo Freshman
_________________________________________________________________
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
--
Jesse Hallam
University of Waterloo Freshman