Re: What is the replacement for ios::noreplace in std?
Dennis_at_NoSpam.com
Date: 10/04/04
- Next message: Mike Wahler: "Re: Tutorial for new user?"
- Previous message: Victor Bazarov: "Re: IS this multi-task safe"
- In reply to: John Harrison: "Re: What is the replacement for ios::noreplace in std?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 04 Oct 2004 16:21:15 GMT
"John Harrison" <john_andronicus@hotmail.com> wrote:
>> After working with this for quite a few days I've come to the conclusion
>> that
>> there is no good substitute for ios::noreplace.
>
>Why not? What was wrong with your solution (and mine)?
The reason the <fstream> replacement didn't work is complicated but I'll try and
explain. The calling program for my function where the <fstream> code is, puts
that function into a double loop. Each time it calls my function it's giving my
function a file to write to and the calculation results it wants to write in
that file. On the first pass for a given file the function opens a new file and
places a header as the first line in that file and the results on the next line.
On the next pass for a given file the function checks if that file exists with
the ios::noreplace and if the file exists it opens the file for append and
writes the next line. The calling program is writing to a 100+ files.
Now with <fstream> our method of opening the file for input, closing the file if
it exists and then opening the file for append just did not work. For some
reason the append did not work and the line after the header just keep getting
written over. So instead of 5000 lines plus header I ended up with just the
last calc line and a header. I tried many variations but all did not work. So
I went back to <fstream.h>
> After all I would be
>willing to bet that the implementation of noreplace in fstream.h is just
>more C++ code, so have a look in the header file at how they did it.
Hey this is a good idea I'll have to look at how the header implemented the
ios::noreplace.
As far as more code. My Program with <fstream.h> compiled into 108k. With the
<fstream> code my program compiled into 208k . Why the extra 100k? I don't
know. I'm using MS VC++ 6.0 with the latest SP.
>I think you mean 'for ( i=0; i<sMyString.size(); i++)'. Also you could
>consider
Right my typo.
>
>fdebug<<sMyString.c_str();
I tried this but <fstream.h> will not allow it.
Dennis
- Next message: Mike Wahler: "Re: Tutorial for new user?"
- Previous message: Victor Bazarov: "Re: IS this multi-task safe"
- In reply to: John Harrison: "Re: What is the replacement for ios::noreplace in std?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|