[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] C++ problem med ofstream



Tirsdag den 9. august 2005 14:01 skrev Carsten Svaneborg:
> Hej!
>
> Jeg har en problemer med at åbne en ofstream. Jeg har en klasse, der skal
> åbne en fil, klassen nedarves så og her skrives der til fra nogle virtuelle
> funktioner. Filnavnet er identisk i de to tilfælde.
>
>
> Følgende kode fejler med fail bitten sat:

(Øv, sendte fra forkert adresse, her er den igen)

Din eksempel kode er ikke "god nok". Følgende program oversætter fint, og
kører uden fejl (filen oprettes):

#include <fstream>
#include <iostream>
using namespace std;

char * fnam = "/usr/tmp/foo";

class ClassSaveSample
{
public:
  ofstream fo;

  void Init(char* _base, char* _ext, bool _doTimeAvg)
  {
    fo.open(fnam);
    if (!fo)
      {
	cerr << "Error opening " << fnam << " for writing\n";

	if (fo.bad()) cerr << " bad ";
	if (fo.fail()) cerr << " fail ";
	if (fo.good()) cerr << " good ";

	exit(1);
      }
  }
};

int main() {
  ClassSaveSample foo;
  foo.Init( "", "", true );
}

Mads

--
Mads Bondo Dydensborg     sslug@sslug    
 http://www.madsdydensborg.dk/

The patent situation well and truly sucks.

         - John Carmack, id Software (Wolfenstein, Doom, Quake), July 2004


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *