Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: strange pro...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 7 Topic 43174 of 48417
Post > Topic >>

Re: strange problem opening ofstream

by rrsettgast@[EMAIL PROTECTED] Feb 11, 2008 at 08:32 AM

Hi,
Thanks for your suggestions. I will try this today. As you have
probably figured out, I am not an engineer first, and a programmer
second. Your suggestion about ofstream being the wrong tool has come
time mind before, but I wouldn't know what else to use...besides a
standard C stream....or just an fstream? So yes i just write binary
files....what would be a more appropriate tool?

Thanks
Randy

On Feb 8, 12:35 pm, James Kanze <james.ka...@[EMAIL PROTECTED]
> wrote:
> On Feb 8, 8:50 pm, rrsettg...@[EMAIL PROTECTED]
 wrote:
>
>
>
> > On Feb 8, 11:24 am, "Daniel T." <danie...@[EMAIL PROTECTED]
> wrote:
> > > How many is "a bunch"? Are you sure they are all getting closed
proper=
ly?
> > Like 10.
> > Yes they are all closed.
> > I do the following commands:
> >   cout<<"  output.is_open() =3D "<<output.is_open()<<endl;
> >   cout<<"  output.fail()    =3D "<<output.fail()<<endl;
> >   cout<<"  output.bad()     =3D "<<output.bad()<<endl;
> >   cout<<"  output.good()    =3D "<<output.good()<<endl;
> > before and after the output.open( filename , ios::binary | ios::out |
> > ios::trunc ); call.
> > i get:
> > before open command
> >   output.is_open() =3D 0
> >   output.fail()    =3D 0
> >   output.bad()     =3D 0
> >   output.good()    =3D 1
> > after open command
> >   output.is_open() =3D 0
> >   output.fail()    =3D 1
> >   output.bad()     =3D 0
> >   output.good()    =3D 0
> > Any way to tell exactly why the open fails?
>
> Not ****tably, but on most implementations, reading errno
> immediately after the open fails (without any intervening code)
> will give a good idea.  Something like:
>
>     stream.open( filename ) ;
>     if ( ! stream ) {
>         int err =3D errno ;
>         std::cerr << "open of " << filename << " failed: "
>             << strerror( err ) << std::endl ;
>     }
>
> One note, however: in your original posting, you said you were
> outputting binary files.  Are you sure ofstream is the right
> tool; it does text formatting, not binary (and it seems a bit
> overweight if the only function in it you use is write()).
>
> --
> James Kanze (GABI Software)             email:james.ka...@[EMAIL PROTECTED]
> Conseils en informatique orient=E9e objet/
>                    Beratung in objektorientierter Datenverarbeitung
> 9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34
 




 7 Posts in Topic:
strange problem opening ofstream
rrsettgast@[EMAIL PROTECT  2008-02-08 10:24:38 
Re: strange problem opening ofstream
"Daniel T." <  2008-02-08 14:24:36 
Re: strange problem opening ofstream
rrsettgast@[EMAIL PROTECT  2008-02-08 11:50:15 
Re: strange problem opening ofstream
"Daniel T." <  2008-02-08 16:40:58 
Re: strange problem opening ofstream
James Kanze <james.kan  2008-02-08 12:35:56 
Re: strange problem opening ofstream
rrsettgast@[EMAIL PROTECT  2008-02-11 08:32:12 
Re: strange problem opening ofstream
James Kanze <james.kan  2008-02-12 01:06:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 10:41:13 CST 2008.