Home > Archive > VC STL > August 2005 > ofstream fails
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hello, using VC6 I have a program (LogDispatch, see codeguru) and I can save
debug output.
It fails and it does so at
void CBenchReceiverDoc::saveAs( const char* strFileName )[color=darkred]
std::istream_iterator< std::string > eos;
std::ostream_iterator< std::string > outputStream( os );//, "\n" );
std::copy( rgLog.begin(), rgLog.end(), outputStream );
}
tried
std::string sFilename("xyzzy.txt");
std::ofstream osScript ( sFilename.c_str(), std::ios::out |
std::ios::trunc );
and it fails too.
Everything compiles ok, but on executions I get " The instruction at...
referenced at 0x0203E, Memory could not be read"
I tried with the simplest of programs, yet it fails, is this a VC++ problem?
ANyone with a solution?
| |
| Ulrich Eckhardt 2005-08-05, 9:03 am |
| revo wrote:
> It fails and it does so at
> void CBenchReceiverDoc::saveAs( const char* strFileName )
I assume that is the line, right? If so, the only way it could fail is if
the given pointer was bogus, including a null pointer. Try stepping there
with a debugger and take a look at what it points to - if it can't be read,
the pointer is probably invalid.
[color=darkred]
> tried
> std::string sFilename("xyzzy.txt");
> std::ofstream osScript ( sFilename.c_str(), std::ios::out |
> std::ios::trunc );
I would have tried the next easiest thing:
std::ofstream out( "aoeui.txt");
the ios::out is always on for _O_streams, and the ios::trunc is default,
btw.
> Everything compiles ok, but on executions I get " The instruction at...
> referenced at 0x0203E, Memory could not be read"
Start a new project, with just an empty main(), add <ostream> and <fstream>
and then try to write to a file. If this fails, your VC6 setup is indeed
broken and you probably need to reinstall it.
> I tried with the simplest of programs, yet it fails, is this a VC++
> problem?
Works for me, so it's not a general problem.
Uli
| |
|
| Yes, it works in another project.
Switched of precompiled headers and voila, working.
Still don't understand it though, must be some messy bug.
However, it's running now, release debug information and savable in a file,
great!
Thank you.
"Ulrich Eckhardt" <eckhardt@satorlaser.com> wrote in message
news:vlvbs2-m8a.ln1@ oc.satorlaser-intern.com...
> revo wrote:
>
> I assume that is the line, right? If so, the only way it could fail is if
> the given pointer was bogus, including a null pointer. Try stepping there
> with a debugger and take a look at what it points to - if it can't be
> read,
> the pointer is probably invalid.
>
>
> I would have tried the next easiest thing:
> std::ofstream out( "aoeui.txt");
> the ios::out is always on for _O_streams, and the ios::trunc is default,
> btw.
>
>
> Start a new project, with just an empty main(), add <ostream> and
> <fstream>
> and then try to write to a file. If this fails, your VC6 setup is indeed
> broken and you probably need to reinstall it.
>
>
> Works for me, so it's not a general problem.
>
> Uli
>
| |
|
| It seems that the precompiled headers were accompanied by inserting
#include<vector>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
which when removed force the error in runtime.
put it back in and all is fine, strange huh?
"Ulrich Eckhardt" <eckhardt@satorlaser.com> wrote in message
news:vlvbs2-m8a.ln1@ oc.satorlaser-intern.com...
> revo wrote:
>
> I assume that is the line, right? If so, the only way it could fail is if
> the given pointer was bogus, including a null pointer. Try stepping there
> with a debugger and take a look at what it points to - if it can't be
> read,
> the pointer is probably invalid.
>
>
> I would have tried the next easiest thing:
> std::ofstream out( "aoeui.txt");
> the ios::out is always on for _O_streams, and the ios::trunc is default,
> btw.
>
>
> Start a new project, with just an empty main(), add <ostream> and
> <fstream>
> and then try to write to a file. If this fails, your VC6 setup is indeed
> broken and you probably need to reinstall it.
>
>
> Works for me, so it's not a general problem.
>
> Uli
>
|
|
|
|
|