[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++] skrive logfil




Kristian Nørgaard <sslug@sslug> wrote on 20-08-2004
16:21:55:

> Jeg har (stadig) et lille log fil projekt kørende, men min viden om
> filstrømme o.lign. er begrænset.
>
> Bør jeg åbne/lukke en logfil for hver sætning der skrives? (Så har jeg
> vel mest mulig info, hvis programmet går ned...?)
>
> Eller er det for resourcekrævende?
>
> Bør jeg i stedet åbne filen for skrivning én gang for alle i starten af
> programmet?
> Kan jeg overhovedet det, i en kort lille test synes det mig som at filen
> lukkes, når jeg forlader den sub-rutine hvor den er åbnet?
>
> Nogen gode links til noget om filstrømme o.lign.
>
> /Kristian


Hvis du bruger C++ filstrømme vil std::basic_ostream<.> destructoren blive
kaldt ved termination af program denne destruerer den implicit associerede
std::basic_streambuf<.>* hvilket skulle medføre at std::basic_filebuf<.>
både flush()'er og close()'r  -- altsammen ifølge ISO/IEC14882:1998(E)

Jeg har oplevet at dette ikke altid sker -- specielt i forbindelse med
assert(false)(og MS-DOG) -- hvilket egentlig godt kan tilgives.

I C++ bør du huske at flushe en gang i mellem.
I C bør du huske at du er på "Herrens Mark" (heldigvis).


Hej fra Nils


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 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] *